public synchronized Object get(long timeout, TimeUnit tunit) throws InterruptedException, ExecutionException, TimeoutException { waitFor(tunit.convert(timeout, TimeUnit.MILLISECONDS)); if (!completed) { throw new TimeoutException("Timeout when waiting for a result"); } return getResult(); }
return doExchange(x, false, 0); } catch (TimeoutException cannotHappen) { throw new Error(cannotHappen.getMessage());
switch (ensureData(timeout)) { case EOF: return -1; case TIMEOUT: throw new TimeoutException("read timeout"); default: break;
return dowait(false, 0L); } catch (TimeoutException toe) { throw new Error(toe.getMessage()); // cannot happen;
switch (ensureData(timeout)) { case EOF: return -1; case TIMEOUT: throw new TimeoutException("read timeout"); default: break;
throw new TimeoutException(); throw interrupted; else // must be timeout throw new TimeoutException();
throw new TimeoutException(); throw interrupted; else // must be timeout throw new TimeoutException();
throw new TimeoutException(); throw interrupted; else // must be timeout throw new TimeoutException();
int read(long timeout) throws IOException, TimeoutException { switch (ensureData(timeout)) { case EOF: return -1; case TIMEOUT: throw new TimeoutException("read timeout"); default: break;
/** * Waits for the task to complete for timeout nanoseconds or throw * TimeoutException if still not completed after that * PRE: lock owned */ private void waitFor(long nanos) throws InterruptedException, TimeoutException { if (nanos < 0) throw new IllegalArgumentException(); if (isDone()) return; long deadline = Utils.nanoTime() + nanos; while (nanos > 0) { TimeUnit.NANOSECONDS.timedWait(this, nanos); if (isDone()) return; nanos = deadline - Utils.nanoTime(); } throw new TimeoutException(); }
/** * Waits for the task to complete for timeout nanoseconds or throw * TimeoutException if still not completed after that * PRE: lock owned */ private void waitFor(long nanos) throws InterruptedException, TimeoutException { if (nanos < 0) throw new IllegalArgumentException(); if (isDone()) return; long deadline = Utils.nanoTime() + nanos; while (nanos > 0) { TimeUnit.NANOSECONDS.timedWait(this, nanos); if (isDone()) return; nanos = deadline - Utils.nanoTime(); } throw new TimeoutException(); }
/** * Waits for the task to complete for timeout nanoseconds or throw * TimeoutException if still not completed after that * PRE: lock owned */ private void waitFor(long nanos) throws InterruptedException, TimeoutException { if (nanos < 0) throw new IllegalArgumentException(); if (isDone()) return; long deadline = Utils.nanoTime() + nanos; while (nanos > 0) { TimeUnit.NANOSECONDS.timedWait(this, nanos); if (isDone()) return; nanos = deadline - Utils.nanoTime(); } throw new TimeoutException(); }
f = ecs.poll(nanos, TimeUnit.NANOSECONDS); if (f == null) throw new TimeoutException(); long now = Utils.nanoTime(); nanos -= now - lastTime;
f = ecs.poll(nanos, TimeUnit.NANOSECONDS); if (f == null) throw new TimeoutException(); long now = Utils.nanoTime(); nanos -= now - lastTime;
f = ecs.poll(nanos, TimeUnit.NANOSECONDS); if (f == null) throw new TimeoutException(); long now = Utils.nanoTime(); nanos -= now - lastTime;