Skip to content

Commit

Permalink
ns
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Apr 22, 2024
1 parent ae76cff commit acf2cdf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/junit-functional/org/jgroups/tests/RingBufferSeqnoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ public void testConcurrentAdd() {
adders[i].start();
}

Util.sleep(1000);
System.out.println("releasing threads");
latch.countDown();
System.out.print("waiting for threads to be done: ");
Expand All @@ -459,6 +458,8 @@ public void testConcurrentAdd() {
e.printStackTrace();
}
}
for(Adder adder: adders)
assert adder.success();
System.out.println("OK");
System.out.println("buf = " + buf);
assert buf.size() == NUM;
Expand All @@ -482,8 +483,7 @@ public void testConcurrentAddAndRemove() throws InterruptedException {
adders[i].start();
}

Util.sleep(1000);
System.out.println("releasing threads");
System.out.println("starting threads");
latch.countDown();
System.out.print("waiting for threads to be done: ");

Expand Down Expand Up @@ -517,7 +517,7 @@ public void run() {
assert list.size() == 10;
for(int i=6; i <=15; i++)
assert list.contains(i);
assertIndices(buf, 15, 5);
assertIndices(buf, 15, 15);
}

public void testPurge() {
Expand Down Expand Up @@ -608,21 +608,24 @@ protected static <T> void assertIndices(RingBufferSeqno<T> buf, long low, long h
}

protected static class Adder extends Thread {
protected final CountDownLatch latch;
protected final int seqno;
protected final CountDownLatch latch;
protected final int seqno;
protected final RingBufferSeqno<Integer> buf;
protected boolean success;

public Adder(CountDownLatch latch, int seqno, RingBufferSeqno<Integer> buf) {
this.latch=latch;
this.seqno=seqno;
this.buf=buf;
}

public boolean success() {return success;}

public void run() {
try {
latch.await();
Util.sleepRandom(10, 500);
buf.add(seqno, seqno, true);
success=buf.add(seqno, seqno, true);
}
catch(InterruptedException e) {
e.printStackTrace();
Expand Down

0 comments on commit acf2cdf

Please sign in to comment.