private void immediateExecHelper() { // final FibersMonitor monitor = getMonitor(); // if (monitor != null) // monitor.fiberResumed(); this.noPreempt = true; //this.inExec = true; task.doExec(); }
public final Fiber<V> joinNoSuspend(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { task.get(timeout, unit); return this; }
@Override public final Object getBlocker() { return task.getBlocker(); }
Object getUnparker() { return task.getUnparker(); }
StackTraceElement[] getUnparkStackTrace() { return task.getUnparkStackTrace(); }
/** * * @return {@code this} */ @Override public final Fiber<V> start() { if (!casState(State.NEW, State.STARTED)) { if (state == State.TERMINATED && future().isCancelled()) return this; throw new IllegalThreadStateException("Fiber has already been started or has died"); } getMonitor().fiberStarted(this); task.submit(); return this; }
this.getStackTrace = false; task.doPark(false); // now we can complete parking
/** * Returns {@code true} iff we've been suspended and then resumed. * (The return value in the Java code is actually ignored. It is generated and injected in InstrumentMethod.accept()) * <p/> * * @param blocker * @param postParkAction * @param timeout * @param unit * @return {@code true} if this fiber actually parked; {@code false} otherwise (if the lease was already available). * @throws SuspendExecution */ private boolean park1(Object blocker, ParkAction postParkAction, long timeout, TimeUnit unit) throws SuspendExecution { record(1, "Fiber", "park", "Parking %s blocker: %s", this, blocker); if (isRecordingLevel(2) && !getStackTrace) record(2, "Fiber", "park", "Parking %s at %s", this, Arrays.toString(getStackTrace())); if (prePark != null) prePark.run(this); this.postPark = postParkAction; if (timeout > 0 && unit != null) this.timeoutTask = scheduler.schedule(this, blocker, timeout, unit); return task.park(blocker, postParkAction != null); // postParkActions != null iff parking for FiberAsync }
/** * Unparks a fiber that's been deserialized (with the help of {@link #getFiberSerializer()} * * @param f The deserialized fiber * @param scheduler The {@link FiberScheduler} to use for scheduling the fiber. * @return The fiber */ public static <V> Fiber<V> unparkDeserialized(Fiber<V> f, FiberScheduler scheduler) { f.record(1, "Fiber", "unparkDeserialized", "Deserialized fiber %s", f); final Thread currentThread = Thread.currentThread(); f.fiberRef = new DummyRunnable(f); f.fid = nextFiberId(); f.scheduler = scheduler; f.task = scheduler.newFiberTask(f); f.task.setState(FiberTask.PARKED); if (USE_VAL_FOR_RESULT /*&& !isVoidResult(target)*/) f.result = new Val<V>(); f.contextClassLoader = ThreadAccess.getContextClassLoader(currentThread); if (MAINTAIN_ACCESS_CONTROL_CONTEXT) f.inheritedAccessControlContext = AccessController.getContext(); f.record(1, "Fiber", "unparkDeserialized", "Unparking deserialized fiber %s", f); f.unpark(SERIALIZER_BLOCKER); return f; }
public final Fiber<V> joinNoSuspend() throws ExecutionException, InterruptedException { task.get(); return this; }