@Override public void run() { awaitUninterruptibly(beforeFunction); } });
@Override public void run() { awaitUninterruptibly(beforeFunction); } });
@Override public void run() { awaitUninterruptibly(beforeFunction); } });
@Override public T apply(T key) { awaitUninterruptibly(delayLatch); return key; } }
void awaitInLoop() { Uninterruptibles.awaitUninterruptibly(completedIteration); } }
@Override protected void implCloseChannel() { Uninterruptibles.awaitUninterruptibly(exitClose); }
@Override public void failure(Service service) { failEnter.countDown(); // block until after the service manager is shutdown Uninterruptibles.awaitUninterruptibly(failLeave); } });
@Override public void execute(Runnable task) { if (future.set(null)) { awaitUninterruptibly(latch); } throw new RejectedExecutionException(); } };
@Override public ListenableFuture<String> apply(Integer input) throws Exception { switch (input) { case VALID_INPUT_DATA: outputFuture.set(RESULT_DATA); break; case SLOW_OUTPUT_VALID_INPUT_DATA: break; // do nothing to the result case SLOW_FUNC_VALID_INPUT_DATA: funcIsWaitingLatch.countDown(); awaitUninterruptibly(funcCompletionLatch); break; case EXCEPTION_DATA: throw EXCEPTION; } return outputFuture; } }
private void enterSatisfyGuardAndLeaveInAnotherThread() { final CountDownLatch startedLatch = new CountDownLatch(1); startThread( new Runnable() { @Override public void run() { startedLatch.countDown(); enterSatisfyGuardAndLeaveInCurrentThread(); } }); awaitUninterruptibly(startedLatch); }
@Override public Object load(String key) { callCount.incrementAndGet(); assertTrue(Uninterruptibles.awaitUninterruptibly(startSignal, 300, TimeUnit.SECONDS)); return result; } });
@Override public String load(String key) throws Exception { callCount.incrementAndGet(); assertTrue(Uninterruptibles.awaitUninterruptibly(startSignal, 300, TimeUnit.SECONDS)); throw e; } });
@Override public String load(String key) { computationStarted.countDown(); assertTrue(Uninterruptibles.awaitUninterruptibly(letGetFinishSignal, 300, TimeUnit.SECONDS)); return key + suffix; } };
@Override public String load(String key) { if (shouldWait.get()) { assertTrue(Uninterruptibles.awaitUninterruptibly(computingLatch, 300, TimeUnit.MINUTES)); } return key; } };
private void enterAndRemainOccupyingInAnotherThread() { final CountDownLatch enteredLatch = new CountDownLatch(1); startThread( new Runnable() { @Override public void run() { monitor.enter(); try { enteredLatch.countDown(); awaitUninterruptibly(tearDownLatch); guard.setSatisfied(true); } finally { monitor.leave(); } } }); awaitUninterruptibly(enteredLatch); }
@Override public void run() { monitor.enter(); try { enteredLatch.countDown(); awaitUninterruptibly(tearDownLatch); guard.setSatisfied(true); } finally { monitor.leave(); } } });
public void testConditionAwaitTimeoutNotExceeded() { Stopwatch stopwatch = Stopwatch.createStarted(); Condition condition = TestCondition.createAndSignalAfter(500, MILLISECONDS); boolean signaledBeforeTimeout = awaitUninterruptibly(condition, 1500, MILLISECONDS); assertTrue(signaledBeforeTimeout); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); assertNotInterrupted(); }
public void testConditionAwaitTimeoutExceeded() { Stopwatch stopwatch = Stopwatch.createStarted(); Condition condition = TestCondition.create(); boolean signaledBeforeTimeout = awaitUninterruptibly(condition, 500, MILLISECONDS); assertFalse(signaledBeforeTimeout); assertAtLeastTimePassed(stopwatch, 500); assertNotInterrupted(); }
public void testConditionAwaitInterruptedTimeoutExceeded() { Stopwatch stopwatch = Stopwatch.createStarted(); Condition condition = TestCondition.create(); requestInterruptIn(500); boolean signaledBeforeTimeout = awaitUninterruptibly(condition, 1000, MILLISECONDS); assertFalse(signaledBeforeTimeout); assertAtLeastTimePassed(stopwatch, 1000); assertInterrupted(); }
public void testConditionAwaitInterruptedTimeoutNotExceeded() { Stopwatch stopwatch = Stopwatch.createStarted(); Condition condition = TestCondition.createAndSignalAfter(1000, MILLISECONDS); requestInterruptIn(500); boolean signaledBeforeTimeout = awaitUninterruptibly(condition, 1500, MILLISECONDS); assertTrue(signaledBeforeTimeout); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); assertInterrupted(); }