@Override public Object getBlocker() { return fiber.getBlocker(); }
@Override public Object getBlocker() { return fiber.getBlocker(); }
@Override public void signal() { if (owner.getBlocker() == this) owner.unpark(); }
private boolean tryUnpark(Object unblocker, long timeout, TimeUnit unit) { long start = 0; for (int i = 0;; i++) { Object b = getBlocker(); boolean tu; if ((unblocker != null ? b == unblocker : true) && (tu = task.tryUnpark(unblocker))) return true; if ((start = isTimeoutExpired(i, start, timeout, unit)) < 0) return false; } }
/** * Executes LWT on this thread, after waiting until the given blocker is indeed the LWT's blocker, and that the LWT is not being run concurrently. * * @param blocker * @return */ public final boolean exec(Object blocker) { for (int i = 0; i < 30; i++) { if (getBlocker() == blocker && fjTask.tryUnpark()) { fjTask.exec(); return true; } } return false; }
private FiberInfo execFiberInfo(long timeout, TimeUnit unit) { if (!tryUnpark(null, timeout, unit)) return null; final State s = this.state; this.noPreempt = true; final StackTraceElement[] st = execStackTrace1(); final Object blocker = getBlocker(); return makeFiberInfo(s, blocker, st); }
/** * Executes fiber on this thread, after waiting until the given blocker is indeed the fiber's blocker, and that the fiber is not being run concurrently. * * @param blocker * @return {@code true} if the task has been executed by this method; {@code false} otherwise. */ final boolean exec(Object blocker, ParkAction prePark) { if (!scheduler.isCurrentThreadInScheduler()) return false; record(1, "Fiber", "exec", "Blocker %s attempting to immediately execute %s", blocker, this); if (blocker != getBlocker() || !task.tryUnpark(blocker)) { record(1, "Fiber", "exec", "Blocker %s attempt to immediately execute %s FAILED", blocker, this); return false; } this.prePark = prePark; immediateExecHelper(); return true; }
State s; if ((s = state) == State.WAITING || s == State.TIMED_WAITING) { Object blocker = getBlocker(); if ((s = state) == State.WAITING || s == State.TIMED_WAITING) return makeFiberInfo(s, blocker, null);