@Override protected boolean exec1() { return fiber.exec(); }
@Override public void signalAndTryToExecNow() { if (!owner.exec(this)) signal(); } }
private void fire(Fiber fiber) { // if (Thread.currentThread() != registrationThread) // while (!registrationComplete); // spin if (immediateExec) { fiber.record(1, "FiberAsync", "fire", "%s - Immediate exec of fiber %s", this, fiber); if (!fiber.exec(this, new Fiber.ParkAction() { public void run(Fiber current) { prepark(); } })) { final boolean timeout = (deadline > 0 && System.nanoTime() >= deadline); final Exception ex = timeout ? new TimeoutException() : new RuntimeException("Failed to exec fiber " + fiber + " in thread " + Thread.currentThread()); this.exception = ex; fiber.unpark(this); if (!timeout) throw (RuntimeException) ex; } } else fiber.unpark(this); }
private void parkAndUnpark1(Fiber other, Object blocker, long timeout, TimeUnit unit) throws SuspendExecution { record(1, "Fiber", "parkAndUnpark", "Parking %s and unparking %s blocker: %s", this, other, blocker); if (!other.exec(blocker, timeout, unit)) other.unpark(blocker); park1(blocker, null, -1, null); }
private void yieldAndUnpark1(Fiber other, Object blocker, long timeout, TimeUnit unit) throws SuspendExecution { record(1, "Fiber", "yieldAndUnpark", "Yielding %s and unparking %s blocker: %s", this, other, blocker); if (!other.exec(blocker, timeout, unit)) { other.unpark(blocker); yield1(); } }
@Override public boolean doExec() { this.parkExclusive = false; this.blocker = null; try { onExec(); boolean res = fiber.exec(); onCompletion(res); return res; } catch (Throwable t) { onException(t); return true; } }