/** * Has this timeout expired * * @return true if expired */ public boolean isExpired() { return getTime() <= 0; }
@Override public T apply(final CompletionService<T> completionService) { try { final Future<T> future = completionService.poll(timeout.getTime(), timeout.getUnit()); if (future == null) { cancelRemaining(); throw timeout.getTimeoutException(); } futures.remove(future); return future.get(); } catch (final InterruptedException e) { throw new RuntimeInterruptedException(e); } catch (final ExecutionException e) { throw new RuntimeExecutionException(e); } }
public boolean await(final long time, final TimeUnit unit) { final Timeout timeout = Timeout.getNanosTimeout(time, unit); try { return future.get(timeout.getTime(), timeout.getUnit()).await(timeout.getTime(), timeout.getUnit()); } catch (final ExecutionException e) { throw new RuntimeException(e); } catch (final TimeoutException e) { return false; } catch (final InterruptedException e) { throw new RuntimeInterruptedException(e); } }
void await(final Awaitable waitable) throws TimeoutException, InterruptedException { if (!waitable.await(getTime(), getUnit())) { throwTimeoutException(); } }
try if (!result.await(timeout.getTime(), timeout.getUnit()))