/** * Waits for the task to complete. * PRE: lock owned */ private void waitFor() throws InterruptedException { while (!isDone()) { wait(); } }
/** * Waits for the task to complete. * PRE: lock owned */ private void waitFor() throws InterruptedException { while (!isDone()) { wait(); } }
/** * Waits for the task to complete. * PRE: lock owned */ private void waitFor() throws InterruptedException { while (!isDone()) { wait(); } }
/** * 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(); }