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) { if (tasks == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
RExecutorBatchFuture future = submit(tasks.toArray(new Callable[tasks.size()])); List<RExecutorFuture<?>> futures = new ArrayList<RExecutorFuture<?>>();
io.netty.util.concurrent.Future<T> result = poll(future.getTaskFutures(), timeout, unit); 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) { if (result == null) {
throw new TimeoutException(); throw new TimeoutException();
} }
for (RExecutorFuture<?> f : future.getTaskFutures()) { for (RExecutorFuture<?> f : futures) {
f.cancel(true); f.cancel(true);
} }
return result.getNow(); return result.getNow();

Loading…
Cancel
Save