@Test public void isolate() throws CheckedFutureException { ExecutorService es = Executors.newCachedThreadPool(); try { FuturePool pool = FuturePool.apply(es); Thread originalThread = Thread.currentThread(); Future<Integer> future = pool.isolate(() -> { assertNotEquals(originalThread, Thread.currentThread()); return Future.value(1); }); assertEquals(new Integer(1), get(future)); } finally { es.shutdown(); } }
public final <T> Future<T> isolate(final Supplier<Future<T>> s) { return Future.flatten(async(s)); }
FuturePool { public final <T> Future<T> isolate(final Supplier<Future<T>> s) { return Future.flatten(async(s)); } }
FuturePool { public final <T> Future<T> isolate(final Supplier<Future<T>> s) { return Future.flatten(async(s)); } private  FuturePool(final ExecutorService executor); }
FuturePool { public final <T> Future<T> isolate(final Supplier<Future<T>> s) { return Future.flatten(async(s)); } private  FuturePool(final ExecutorService executor); static FuturePool apply(final ExecutorService executor); final Future<T> isolate(final Supplier<Future<T>> s); final Future<T> async(final Supplier<T> s); }
FuturePool { public final <T> Future<T> isolate(final Supplier<Future<T>> s) { return Future.flatten(async(s)); } private  FuturePool(final ExecutorService executor); static FuturePool apply(final ExecutorService executor); final Future<T> isolate(final Supplier<Future<T>> s); final Future<T> async(final Supplier<T> s);  }