/** * Wait on all the {@link IoFuture}s we get, or until one of the {@link IoFuture}s is interrupted * * @param futures The {@link IoFuture}s we are waiting on * @throws InterruptedException If one of the {@link IoFuture} is interrupted */ public static void await(Iterable<? extends IoFuture> futures) throws InterruptedException { for (IoFuture f : futures) { f.await(); } }
private static boolean await0(Iterable<? extends IoFuture> futures, long timeoutMillis, boolean interruptable) throws InterruptedException { long startTime = timeoutMillis <= 0 ? 0 : System.currentTimeMillis(); long waitTime = timeoutMillis; boolean lastComplete = true; Iterator<? extends IoFuture> i = futures.iterator(); while (i.hasNext()) { IoFuture f = i.next(); do { if (interruptable) { lastComplete = f.await(waitTime); } else { lastComplete = f.awaitUninterruptibly(waitTime); } waitTime = timeoutMillis - (System.currentTimeMillis() - startTime); if (lastComplete || waitTime <= 0) { break; } } while (!lastComplete); if (waitTime <= 0) { break; } } return lastComplete && !i.hasNext(); }
lastComplete = f.await(waitTime); } else { lastComplete = f.awaitUninterruptibly(waitTime);
/** * Wait on all the {@link IoFuture}s we get, or until one of the {@link IoFuture}s is interrupted * * @param futures The {@link IoFuture}s we are waiting on * @throws InterruptedException If one of the {@link IoFuture} is interrupted */ public static void await(Iterable<? extends IoFuture> futures) throws InterruptedException { for (IoFuture f : futures) { f.await(); } }
lastComplete = f.await(waitTime); } else { lastComplete = f.awaitUninterruptibly(waitTime);
public static void await(Iterable<? extends IoFuture> futures) throws InterruptedException { for (IoFuture f: futures) { f.await(); } }