Isolates the execution of the supplier on this future pool. @param s the supplier. @return a future with the result of the supplier.
(final Supplier<T> s)
| 67 | * @return a future with the result of the supplier. |
| 68 | */ |
| 69 | public final <T> Future<T> async(final Supplier<T> s) { |
| 70 | try { |
| 71 | final AsyncPromise<T> p = new AsyncPromise<>(s); |
| 72 | executor.submit(p); |
| 73 | return p; |
| 74 | } catch (final RejectedExecutionException ex) { |
| 75 | return Future.exception(ex); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | final class AsyncPromise<T> extends Promise<T> implements Runnable { |