void resetForTxn() { synchronized (barrier1) { if (barrier1.isBroken()) { barrier1.reset(); } } synchronized (barrier2) { if (barrier2.isBroken()) { barrier2.reset(); } } synchronized (txnBarrier) { if (txnBarrier.isBroken()) { txnBarrier.reset(); } } try { txnBarrier.await(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public Boolean call() throws Exception { for (int i = 0; i < 100; i++) { Thread.sleep(RANDOM.nextInt(100)); if (fh == null) { fh = ep.insert("" + index); } else { if (RANDOM.nextInt(100) < 70) { ep.delete(fh); fh = null; } else { ep.update(fh, "" + index); } } if (i % 10 == 9) { if (!barrier.isBroken()) { barrier.await(); } else { fail( "This is not a bug in phreak synchronization, but a for some reason the barrier is broken, run the test again"); return false; } } } if (index == deleteIndex) { if (fh != null) { ep.delete(fh); fh = null; } } else if (fh == null) { fh = ep.insert("" + index); } return true; }