@Override public void andThen(ExecutionCallback<V> callback, Executor executor) { isNotNull(callback, "callback"); isNotNull(executor, "executor"); Object response = registerWaiter(callback, executor); if (response != VOID) { unblock(callback, executor); } }
@Override public void andThen(ExecutionCallback<V> callback, Executor executor) { isNotNull(callback, "callback"); isNotNull(executor, "executor"); Object response = registerWaiter(callback, executor); if (response != VOID) { unblock(callback, executor); } }
@Override public V get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Object response = registerWaiter(Thread.currentThread(), null); if (response != VOID) { return resolveAndThrowIfException(response); } long deadlineNanos = System.nanoTime() + unit.toNanos(timeout); boolean interrupted = false; try { long timeoutNanos = unit.toNanos(timeout); while (timeoutNanos > 0) { parkNanos(timeoutNanos); timeoutNanos = deadlineNanos - System.nanoTime(); if (isDone()) { return resolveAndThrowIfException(state); } else if (Thread.interrupted()) { interrupted = true; onInterruptDetected(); } } } finally { restoreInterrupt(interrupted); } unregisterWaiter(Thread.currentThread()); throw newTimeoutException(timeout, unit); }
@Override public final V get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Object response = registerWaiter(Thread.currentThread(), null); if (response != VOID) { return resolveAndThrowIfException(response); } long deadlineNanos = System.nanoTime() + unit.toNanos(timeout); boolean interrupted = false; try { long timeoutNanos = unit.toNanos(timeout); while (timeoutNanos > 0) { parkNanos(timeoutNanos); timeoutNanos = deadlineNanos - System.nanoTime(); if (isDone()) { return resolveAndThrowIfException(state); } else if (Thread.interrupted()) { interrupted = true; onInterruptDetected(); } } } finally { restoreInterrupt(interrupted); } unregisterWaiter(Thread.currentThread()); throw newTimeoutException(timeout, unit); }
@Override public final V get() throws InterruptedException, ExecutionException { Object response = registerWaiter(Thread.currentThread(), null); if (response != VOID) { // no registration was done since a value is available. return resolveAndThrowIfException(response); } boolean interrupted = false; try { for (; ; ) { park(); if (isDone()) { return resolveAndThrowIfException(state); } else if (Thread.interrupted()) { interrupted = true; onInterruptDetected(); } } } finally { restoreInterrupt(interrupted); } }
@Override public V get() throws InterruptedException, ExecutionException { Object response = registerWaiter(Thread.currentThread(), null); if (response != VOID) { // no registration was done since a value is available. return resolveAndThrowIfException(response); } boolean interrupted = false; try { for (; ; ) { park(); if (isDone()) { return resolveAndThrowIfException(state); } else if (Thread.interrupted()) { interrupted = true; onInterruptDetected(); } } } finally { restoreInterrupt(interrupted); } }