public static OwnedSynchronizer create(Strand owner) { return create(owner.getUnderlying()); }
public static OwnedSynchronizer create(Object owner) { if (owner instanceof Fiber) return create((Fiber) owner); else if (owner instanceof Thread) return create((Thread) owner); else if (owner instanceof Strand) return create(((Strand) owner).getUnderlying()); else throw new IllegalArgumentException("owner must be a Thread, a Fiber or a Strand, but is " + owner.getClass().getName()); }
public static Strand clone(Strand strand, final SuspendableRunnable target) { if (strand.isAlive()) throw new IllegalStateException("A strand can only be cloned after death. " + strand + " isn't dead."); if (strand instanceof FiberStrand) return clone((Fiber) strand.getUnderlying(), target); if (strand instanceof Fiber) return new Fiber((Fiber) strand, target); else return ThreadStrand.get(cloneThread((Thread) strand.getUnderlying(), toRunnable(target))); }
public static Strand clone(Strand strand, final SuspendableCallable<?> target) { if (strand.isAlive()) throw new IllegalStateException("A strand can only be cloned after death. " + strand + " isn't dead."); if (strand instanceof FiberStrand) return clone((Fiber) strand.getUnderlying(), target); if (strand instanceof Fiber) return new Fiber((Fiber) strand, target); else return ThreadStrand.get(cloneThread((Thread) strand.getUnderlying(), toRunnable(target))); }
/** * Returns the actor associated with the given strand, or {@code null} if none is. */ public static Actor getActor(Strand s) { final ActorRunner runner; if (s.isFiber()) runner = (ActorRunner) ((Fiber) s.getUnderlying()).getTarget(); else runner = (ActorRunner) Strand.unwrapSuspendable(ThreadAccess.getTarget((Thread) s.getUnderlying())); if (runner == null) return null; return runner.getActor(); } //</editor-fold>
Fiber f = (Fiber) collector.getUnderlying(); f.join(); } else