RExecutorService.invokeAny execution optimization

pull/1705/head
Nikita 6 years ago
parent d2ac9ab8d0
commit 6d20c1356c

@ -974,13 +974,18 @@ public class RedissonExecutorService implements RScheduledExecutorService {
if (tasks == null) {
throw new NullPointerException();
}
RExecutorBatchFuture future = submit(tasks.toArray(new Callable[tasks.size()]));
io.netty.util.concurrent.Future<T> result = poll(future.getTaskFutures(), timeout, unit);
List<RExecutorFuture<?>> futures = new ArrayList<RExecutorFuture<?>>();
for (Callable<T> callable : tasks) {
RExecutorFuture<T> future = submit(callable);
futures.add(future);
}
io.netty.util.concurrent.Future<T> result = poll(futures, timeout, unit);
if (result == null) {
throw new TimeoutException();
}
for (RExecutorFuture<?> f : future.getTaskFutures()) {
for (RExecutorFuture<?> f : futures) {
f.cancel(true);
}
return result.getNow();

Loading…
Cancel
Save