/** * Awaits the termination of a given strand. * This method blocks until this strand terminates. * * @param strand the strand to join. May be an object of type {@code Strand}, {@code Fiber} or {@code Thread}. * @throws ExecutionException if this strand has terminated as a result of an uncaught exception * (which will be the {@link Throwable#getCause() cause} of the thrown {@code ExecutionException}. * @throws InterruptedException */ public static void join(Object strand) throws ExecutionException, InterruptedException { Strand.join(strand); }
@Override public void join() throws ExecutionException, InterruptedException { strand.join(); }
@Override public void join(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { strand.join(timeout, unit); }
/** * Awaits the termination of a given strand, at most for the timeout duration specified. * This method blocks until this strand terminates or the timeout elapses. * * @param strand the strand to join. May be an object of type {@code Strand}, {@code Fiber} or {@code Thread}. * @param timeout the maximum duration to wait for the strand to terminate in the time unit specified by {@code unit}. * @param unit the time unit of {@code timeout}. * @throws TimeoutException if this strand did not terminate by the time the timeout has elapsed. * @throws ExecutionException if this strand has terminated as a result of an uncaught exception * (which will be the {@link Throwable#getCause() cause} of the thrown {@code ExecutionException}. * @throws InterruptedException */ public static void join(Object strand, long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { Strand.join(strand, timeout, unit); }
@Override public V get() throws InterruptedException, ExecutionException { if (strand instanceof Fiber) return ((Fiber<V>) strand).get(); else { strand.join(); return result; } }
/** * Awaits the termination of a given strand. * This method blocks until this strand terminates. * * @param strand the strand to join. May be an object of type {@code Strand}, {@code Fiber} or {@code Thread}. * * @throws ExecutionException if this strand has terminated as a result of an uncaught exception * (which will be the {@link Throwable#getCause() cause} of the thrown {@code ExecutionException}. * @throws InterruptedException */ public static void join(Object strand) throws ExecutionException, InterruptedException { if (strand instanceof Strand) ((Strand) strand).join(); else if (strand instanceof Thread) ((Thread) strand).join(); else throw new IllegalArgumentException("Can't join an object of type " + strand.getClass()); }
@Override @Suspendable public void join() throws ExecutionException, InterruptedException { strand.join(); }
@Override public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { if (strand instanceof Fiber) return ((Fiber<V>) strand).get(timeout, unit); else { strand.join(timeout, unit); return result; } }
@Override @Suspendable public void join(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { strand.join(timeout, unit); }
/** * Awaits the termination of a given strand, at most for the timeout duration specified. * This method blocks until this strand terminates or the timeout elapses. * * @param strand the strand to join. May be an object of type {@code Strand}, {@code Fiber} or {@code Thread}. * @param timeout the maximum duration to wait for the strand to terminate in the time unit specified by {@code unit}. * @param unit the time unit of {@code timeout}. * * @throws TimeoutException if this strand did not terminate by the time the timeout has elapsed. * @throws ExecutionException if this strand has terminated as a result of an uncaught exception * (which will be the {@link Throwable#getCause() cause} of the thrown {@code ExecutionException}. * @throws InterruptedException */ public static void join(Object strand, long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { if (strand instanceof Strand) ((Strand) strand).join(timeout, unit); else if (strand instanceof Thread) join(Strand.of(strand), timeout, unit); else throw new IllegalArgumentException("Can't join an object of type " + strand.getClass()); }
@Override @Suspendable public final V get() throws InterruptedException, ExecutionException { final Strand s = strand; if (s == null) throw new IllegalStateException("Actor strand not set (not started?)"); if (s instanceof Fiber) return ((Fiber<V>) s).get(); else { s.join(); return actor.getResult(); } }
@Override @Suspendable public final V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { if (strand instanceof Fiber) return ((Fiber<V>) strand).get(timeout, unit); else { strand.join(timeout, unit); return actor.getResult(); } }
f.join(); } else collector.join(); } catch (ExecutionException ee) { throw new AssertionError(ee);