/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. May * be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied * @throws InterruptedException if interrupted while waiting */ @SuppressWarnings("GoodTime") // should accept a java.time.Duration public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { final long timeoutNanos = toSafeNanos(time, unit); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } if (guard.isSatisfied()) { return true; } if (Thread.interrupted()) { throw new InterruptedException(); } return awaitNanos(guard, timeoutNanos, true); }
for (long remainingNanos = timeoutNanos; ; ) { try { return awaitNanos(guard, remainingNanos, signalBeforeWaiting); } catch (InterruptedException interrupt) { interrupted = true;
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. May * be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied * @throws InterruptedException if interrupted while waiting */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { final long timeoutNanos = toSafeNanos(time, unit); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } if (guard.isSatisfied()) { return true; } if (Thread.interrupted()) { throw new InterruptedException(); } return awaitNanos(guard, timeoutNanos, true); }
satisfied = guard.isSatisfied() || awaitNanos( guard, (startTime == 0L) ? timeoutNanos : remainingNanos(startTime, timeoutNanos),
remainingNanos = remainingNanos(startTime, timeoutNanos); satisfied = awaitNanos(guard, remainingNanos, signalBeforeWaiting);
for (long remainingNanos = timeoutNanos; ; ) { try { return awaitNanos(guard, remainingNanos, signalBeforeWaiting); } catch (InterruptedException interrupt) { interrupted = true;
satisfied = guard.isSatisfied() || awaitNanos( guard, (startTime == 0L) ? timeoutNanos : remainingNanos(startTime, timeoutNanos),
remainingNanos = remainingNanos(startTime, timeoutNanos); satisfied = awaitNanos(guard, remainingNanos, signalBeforeWaiting);
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. * May be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { long timeoutNanos = unit.toNanos(time); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } return guard.isSatisfied() || awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. * May be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { long timeoutNanos = unit.toNanos(time); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } return guard.isSatisfied() || awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. * May be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { long timeoutNanos = unit.toNanos(time); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } return guard.isSatisfied() || awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. * May be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { long timeoutNanos = unit.toNanos(time); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } return guard.isSatisfied() || awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. * May be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { long timeoutNanos = unit.toNanos(time); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } return guard.isSatisfied() || awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. * May be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { long timeoutNanos = unit.toNanos(time); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } return guard.isSatisfied() || awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. May * be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied * @throws InterruptedException if interrupted while waiting */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { final long timeoutNanos = toSafeNanos(time, unit); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } if (guard.isSatisfied()) { return true; } if (Thread.interrupted()) { throw new InterruptedException(); } return awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. * May be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied * @throws InterruptedException if interrupted while waiting */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { final long timeoutNanos = toSafeNanos(time, unit); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } if (guard.isSatisfied()) { return true; } if (Thread.interrupted()) { throw new InterruptedException(); } return awaitNanos(guard, timeoutNanos, true); }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. May * be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied * @throws InterruptedException if interrupted while waiting */ public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { final long timeoutNanos = toSafeNanos(time, unit); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } if (guard.isSatisfied()) { return true; } if (Thread.interrupted()) { throw new InterruptedException(); } return awaitNanos(guard, timeoutNanos, true); }
while (true) { try { return awaitNanos(guard, timeoutNanos, signalBeforeWaiting); } catch (InterruptedException interrupt) { interrupted = true;
boolean threw = true; try { satisfied = guard.isSatisfied() || awaitNanos(guard, timeoutNanos, reentrant); threw = false; return satisfied;
for (long remainingNanos = timeoutNanos;;) { try { return awaitNanos(guard, remainingNanos, signalBeforeWaiting); } catch (InterruptedException interrupt) { interrupted = true;