private T awaitHelper() { if ( Actor.isError(getError()) ) { if ( getError() instanceof Throwable ) { FSTUtil.<RuntimeException>rethrow((Throwable) getError()); return null; // never reached } else { if ( getError() == Timeout.INSTANCE ) { throw new KTimeoutException(); } throw new AwaitException(getError()); } } else { return get(); } }
/** * similar all but map promises to their content * * returns a future which is settled once all promises provided are settled * */ public static <T> IPromise<List<T>> allMapped(List<IPromise<T>> futures) { Promise returned = new Promise(); Promise res = new Promise(); awaitSettle(futures, res); res.then( (r, e) -> { if (r!=null) { returned.resolve(((List<Promise>)r).stream().map(p -> p.get()).collect(Collectors.toList())); } else { returned.complete(null,e); } }); return returned; }
private T awaitHelper() { if ( Actor.isError(getError()) ) { if ( getError() instanceof Throwable ) { FSTUtil.<RuntimeException>rethrow((Throwable) getError()); return null; // never reached } else { if ( getError() == Timeout.INSTANCE ) { throw new KTimeoutException(); } throw new AwaitException(getError()); } } else { return get(); } }
/** * similar all but map promises to their content * * returns a future which is settled once all promises provided are settled * */ public static <T> IPromise<List<T>> allMapped(List<IPromise<T>> futures) { Promise returned = new Promise(); Promise res = new Promise(); awaitSettle(futures, res); res.then( (r, e) -> { if (r!=null) { returned.resolve(((List<Promise>)r).stream().map(p -> p.get()).collect(Collectors.toList())); } else { returned.complete(null,e); } }); return returned; }