private static void park(long time) throws SuspendExecution { if (time != 0) Strand.parkNanos(time); else Strand.park(); } }
public void await() throws SuspendExecution { waiter = Strand.currentStrand(); while (running.get() > 0) { Strand.park(); } } }
/** * Convenience method to park and then check if interrupted * * @return {@code true} if interrupted */ private boolean parkAndCheckInterrupt() throws SuspendExecution { Strand.park(this); return Strand.interrupted(); }
public boolean block() throws InterruptedException, SuspendExecution { if (isReleasable()) return true; else if (!timed) { // System.out.println("PHASER " + (System.currentTimeMillis() % 300000) + " " + phase + " " + Fiber.currentFiber() + " " + Thread.currentThread() + " - BLOCKED"); Strand.park(this); } else if (nanos > 0) Strand.parkNanos(this, nanos); return isReleasable(); } }
/** * Convenience method to park and then check if interrupted * * @return {@code true} if interrupted */ private final boolean parkAndCheckInterrupt() throws SuspendExecution { Strand.park(this); return Strand.interrupted(); }
lastTime = now; } else Strand.park(this);
Strand.park(blocker); } catch (SuspendExecution e) { throw RuntimeSuspendExecution.of(e);
lastTime = now; } else { Strand.park(this);
Strand.park(); } catch (SuspendExecution e) { throw RuntimeSuspendExecution.of(e);
@Override public void await(int iter) throws InterruptedException, SuspendExecution { final int spins; final Fiber<?> fib = Fiber.currentFiber(); if (fib != null) { spins = 0; if (iter > 0) fib.getMonitor().spuriousWakeup(); } else spins = SPINS - iter; if (spins > 0) { if (ThreadLocalRandom.current().nextInt(SPINS) == 0) Strand.yield(); } else { if (isRecording()) record("await", "%s parking", Strand.currentStrand()); Strand.park(owner); if (isRecording()) record("await", "%s awoke", Strand.currentStrand()); } if (Strand.interrupted()) throw new InterruptedException(); }
public static void parkAndUnpark(Strand other, Object blocker) throws SuspendExecution { if (canTransferControl(other)) Fiber.parkAndUnpark((Fiber) other, blocker); else if (!other.isFiber() && !isCurrentFiber()) { // might be made faster on Linux if SwitchTo syscall is introduced into the kernel. other.unpark(blocker); LockSupport.park(blocker); } else { other.unpark(blocker); park(blocker); } }
public static void parkAndUnpark(Strand other) throws SuspendExecution { if (canTransferControl(other)) Fiber.parkAndUnpark((Fiber) other); else if (!other.isFiber() && !isCurrentFiber()) { // might be made faster on Linux if SwitchTo syscall is introduced into the kernel. other.unpark(); LockSupport.park(); } else { other.unpark(); park(); } }
int interruptMode = 0; while (!isOnSyncQueue(node)) { Strand.park(this); if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) break;
/** * Implements uninterruptible condition wait. * <ol> * <li> Save lock state returned by {@link #getState}. * <li> Invoke {@link #release} with saved state as argument, * throwing IllegalMonitorStateException if it fails. * <li> Block until signalled. * <li> Reacquire by invoking specialized version of * {@link #acquire} with saved state as argument. * </ol> */ @Suspendable public final void awaitUninterruptibly() { try { Node node = addConditionWaiter(); int savedState = fullyRelease(node); boolean interrupted = false; while (!isOnSyncQueue(node)) { Strand.park(this); if (Strand.interrupted()) interrupted = true; } if (acquireQueued(node, savedState) || interrupted) selfInterrupt(); } catch (SuspendExecution e) { throw new AssertionError(); } }
/** * Implements uninterruptible condition wait. * <ol> * <li> Save lock state returned by {@link #getState}. * <li> Invoke {@link #release} with saved state as argument, * throwing IllegalMonitorStateException if it fails. * <li> Block until signalled. * <li> Reacquire by invoking specialized version of * {@link #acquire} with saved state as argument. * </ol> */ @Suspendable public final void awaitUninterruptibly() { try { Node node = addConditionWaiter(); long savedState = fullyRelease(node); boolean interrupted = false; while (!isOnSyncQueue(node)) { Strand.park(this); if (Strand.interrupted()) interrupted = true; } if (acquireQueued(node, savedState) || interrupted) selfInterrupt(); } catch (SuspendExecution e) { throw new AssertionError(); } }
int interruptMode = 0; while (!isOnSyncQueue(node)) { Strand.park(this); if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) break;