@Override public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { Preconditions.checkNotNull(tasks, "tasks must not be null!"); return delegate.invokeAll(tasks); }
@Override public <T> List<Future<T>> invokeAll( Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { Preconditions.checkNotNull(tasks, "tasks must not be null!"); Preconditions.checkNotNull(unit, "unit must not be null!"); return delegate.invokeAll(tasks, timeout, unit); }
public <T> void testListeningExecutorServiceInvokeAllJavadocCodeCompiles() throws Exception { ListeningExecutorService executor = newDirectExecutorService(); List<Callable<T>> tasks = ImmutableList.of(); List<? extends Future<?>> unused = executor.invokeAll(tasks); }
List<ListenableFuture<?>> futures = writeVerificationExecutor.invokeAll(verificationTasks).stream() .map(future -> (ListenableFuture<?>) future) .collect(toList());
public void testListeningDecorator() throws Exception { ListeningExecutorService service = listeningDecorator(newDirectExecutorService()); assertSame(service, listeningDecorator(service)); List<Callable<String>> callables = ImmutableList.of(Callables.returning("x")); List<Future<String>> results; results = service.invokeAll(callables); assertThat(getOnlyElement(results)).isInstanceOf(TrustedListenableFutureTask.class); results = service.invokeAll(callables, 1, SECONDS); assertThat(getOnlyElement(results)).isInstanceOf(TrustedListenableFutureTask.class); /* * TODO(cpovirk): move ForwardingTestCase somewhere common, and use it to * test the forwarded methods */ }
@Override public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { return executorServiceDelegate.invokeAll(tasks); }
@Override public <T> List<Future<T>> invokeAll( Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { return executorServiceDelegate.invokeAll(tasks, timeout, unit); }
@Override public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { Preconditions.checkNotNull(tasks, "tasks must not be null!"); return delegate.invokeAll(tasks); }
@Override public <T> List<Future<T>> invokeAll( Collection<? extends Callable<T>> tasks) throws InterruptedException { Preconditions.checkNotNull(tasks, "tasks must not be null!"); return delegate.invokeAll(tasks); }
@Override public <T> List<Future<T>> invokeAll( Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { Preconditions.checkNotNull(tasks, "tasks must not be null!"); Preconditions.checkNotNull(unit, "unit must not be null!"); return delegate.invokeAll(tasks, timeout, unit); }
@Override public <T> List<Future<T>> invokeAll( Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { Preconditions.checkNotNull(tasks, "tasks must not be null!"); Preconditions.checkNotNull(unit, "unit must not be null!"); return delegate.invokeAll(tasks, timeout, unit); }
ListeningExecutorService executor = MoreExecutors.sameThreadExecutor(); List<Future<Object>> futures = executor.invokeAll( singletonList(new Callable<Object>() { @Override public Object call() throws Exception { return 42; } } )); List<Object> r = Lists.newArrayList(); for (Future<Object> future : futures) r.add(future.get());
/** * Softer generic signature * * @see ExecutorService#invokeAll(Collection) */ // guaranteed by ListeningExecutorService#invokeAll contract @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> List<? extends ListenableFuture<T>> invokeAll(Collection<? extends Supplier<? extends T>> tasks, ListeningExecutorService executorService) throws InterruptedException { Collection<Callable<T>> callables = Collections2.transform(tasks, PepperExecutorsHelper.supplierToCallable()); return (List) executorService.invokeAll(callables); }
/** * Softer generic signature * * @see ExecutorService#invokeAll(Collection) */ // guaranteed by ListeningExecutorService#invokeAll contract @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> List<? extends ListenableFuture<T>> invokeAll(Collection<? extends Supplier<? extends T>> tasks, ListeningExecutorService executorService) throws InterruptedException { Collection<Callable<T>> callables = Collections2.transform(tasks, ApexExecutorsHelper.supplierToCallable()); return (List) executorService.invokeAll(callables); }
/** * Softer generic signature * * @see ExecutorService#invokeAll(Collection, long, TimeUnit) */ // guaranteed by ListeningExecutorService#invokeAll contract @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> List<? extends ListenableFuture<T>> invokeAll(Collection<? extends Callable<? extends T>> tasks, ListeningExecutorService executorService, long timeout, TimeUnit unit) throws InterruptedException { // Use transform to workaround Generic limitations in invokeAll Collection<Callable<T>> callables = Collections2.transform(tasks, ApexExecutorsHelper.<T>callableToCallable()); return (List) executorService.invokeAll(callables, timeout, unit); }
/** * Softer generic signature * * @see ExecutorService#invokeAll(Collection, long, TimeUnit) */ // guaranteed by ListeningExecutorService#invokeAll contract @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> List<? extends ListenableFuture<T>> invokeAll(Collection<? extends Callable<? extends T>> tasks, ListeningExecutorService executorService, long timeout, TimeUnit unit) throws InterruptedException { // Use transform to workaround Generic limitations in invokeAll Collection<Callable<T>> callables = Collections2.transform(tasks, PepperExecutorsHelper.<T>callableToCallable()); return (List) executorService.invokeAll(callables, timeout, unit); }
@Override public synchronized <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { List<Future<T>> futures = executor.invokeAll(tasks, timeout, unit); List<Future<T>> manageable = new ArrayList<>(futures.size()); int i = 0; for (Callable<T> callable : tasks) { Task task = getNewTaskFor(callable); task.submitted(futures.get(i)); manageable.add(task); i++; } return manageable; }
@Override public synchronized <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { List<Future<T>> futures = executor.invokeAll(tasks); List<Future<T>> manageable = new ArrayList<>(futures.size()); int i = 0; for (Callable<T> callable : tasks) { Task task = getNewTaskFor(callable); task.submitted(futures.get(i)); manageable.add(task); i++; } return manageable; }
public <T> void testListeningExecutorServiceInvokeAllJavadocCodeCompiles() throws Exception { ListeningExecutorService executor = newDirectExecutorService(); List<Callable<T>> tasks = ImmutableList.of(); List<? extends Future<?>> unused = executor.invokeAll(tasks); }
public void testListeningDecorator() throws Exception { ListeningExecutorService service = listeningDecorator(newDirectExecutorService()); assertSame(service, listeningDecorator(service)); List<Callable<String>> callables = ImmutableList.of(Callables.returning("x")); List<Future<String>> results; results = service.invokeAll(callables); assertThat(getOnlyElement(results)).isInstanceOf(TrustedListenableFutureTask.class); results = service.invokeAll(callables, 1, SECONDS); assertThat(getOnlyElement(results)).isInstanceOf(TrustedListenableFutureTask.class); /* * TODO(cpovirk): move ForwardingTestCase somewhere common, and use it to * test the forwarded methods */ }