/** * Blocks on the input fibers and creates a new list from the results. The result list is the same order as the * input list. * * @param fibers to combine */ @SuppressWarnings("unchecked") public static <V> List<V> get(Fiber<V>... fibers) throws InterruptedException { return FiberUtil.get(fibers); }
/** * Blocks on the input fibers and creates a new list from the results. The result list is the same order as the * input list. * * @param fibers to combine */ public static <V> List<V> get(List<Fiber<V>> fibers) throws InterruptedException { return FiberUtil.get(fibers); }
/** * Blocks on the input fibers and creates a new list from the results. The result list is the same order as the * input list. * * @param timeout to wait for all requests to complete * @param unit the time is in * @param fibers to combine */ public static <V> List<V> get(long timeout, TimeUnit unit, List<Fiber<V>> fibers) throws InterruptedException, TimeoutException { return FiberUtil.get(timeout, unit, fibers); }
/** * Blocks on the input fibers and creates a new list from the results. The result list is the same order as the * input list. * * @param time to wait for all requests to complete * @param unit the time is in * @param fibers to combine */ @SuppressWarnings("unchecked") public static <V> List<V> get(long time, TimeUnit unit, Fiber<V>... fibers) throws InterruptedException, TimeoutException { return FiberUtil.get(time, unit, fibers); }
/** * Blocks on the input fibers and creates a new list from the results. The result list is the same order as the * input list. * * @param fibers to combine */ public static <V> List<V> get(Fiber<V>... fibers) throws InterruptedException { return get(Arrays.asList(fibers)); }
/** * Blocks on the input fibers and creates a new list from the results. The result list is the same order as the * input list. * * @param time to wait for all requests to complete * @param unit the time is in * @param fibers to combine */ public static <V> List<V> get(final long time, final TimeUnit unit, final Fiber<V>... fibers) throws InterruptedException, TimeoutException { return get(time, unit, Arrays.asList(fibers)); }
/** * Blocks on the input fibers and creates a new list from the results. The result list is the same order as the * input list. * * @param timeout to wait for all requests to complete * @param unit the time is in * @param fibers to combine */ public static <V> List<V> get(long timeout, TimeUnit unit, List<Fiber<V>> fibers) throws InterruptedException, TimeoutException { if (unit == null) return get(fibers); if (timeout < 0) timeout = 0; final List<V> results = new ArrayList<>(fibers.size()); long left = unit.toNanos(timeout); final long deadline = System.nanoTime() + left; //TODO on interrupt, should all input fibers be canceled? try { for (final Fiber<V> f : fibers) { if (left >= 0) { results.add(f.get(left, TimeUnit.NANOSECONDS)); left = deadline - System.nanoTime(); } else throw new TimeoutException("timed out sequencing fiber results"); } return Collections.unmodifiableList(results); } catch (ExecutionException e) { throw Exceptions.rethrowUnwrap(e); } }