@Override public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size()); List<Future<T>> result = new ArrayList<Future<T>>(tasks.size()); for (Callable<T> task : tasks) { futures.add(submit(task)); } for (Future<T> future : futures) { Object value; try { value = future.get(); } catch (ExecutionException e) { value = e; } result.add(new CompletedFuture<T>(getNodeEngine().getSerializationService(), value, getAsyncExecutor())); } return result; }
@Override public void andThen(ExecutionCallback<V> callback) { andThen(callback, userExecutor); }
@Override public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return get(); }
@Override public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size()); List<Future<T>> result = new ArrayList<Future<T>>(tasks.size()); for (Callable<T> task : tasks) { futures.add(submit(task)); } for (Future<T> future : futures) { Object value; try { value = future.get(); } catch (ExecutionException e) { value = e; } result.add(new CompletedFuture<T>(getNodeEngine().getSerializationService(), value, getAsyncExecutor())); } return result; }
@Override public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return get(); }
@Override public void andThen(ExecutionCallback<V> callback) { andThen(callback, userExecutor); }
@Override public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { final List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size()); final List<Future<T>> result = new ArrayList<Future<T>>(tasks.size()); for (Callable<T> task : tasks) { futures.add(submitToRandomInternal(task, null, true)); } Executor userExecutor = getContext().getExecutionService().getUserExecutor(); for (Future<T> future : futures) { Object value = retrieveResult(future); result.add(new CompletedFuture<T>(getSerializationService(), value, userExecutor)); } return result; }
@Override public V join() { try { // this method is quite inefficient when there is unchecked exception, because it will be wrapped // in a ExecutionException, and then it is unwrapped again. return get(); } catch (Throwable throwable) { throw rethrow(throwable); } }
@Override public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { final List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size()); final List<Future<T>> result = new ArrayList<Future<T>>(tasks.size()); for (Callable<T> task : tasks) { futures.add(submitToRandomInternal(task, null, true)); } Executor userExecutor = getContext().getExecutionService().getUserExecutor(); for (Future<T> future : futures) { Object value = retrieveResult(future); result.add(new CompletedFuture<T>(getSerializationService(), value, userExecutor)); } return result; }
@Override public V join() { try { // this method is quite inefficient when there is unchecked exception, because it will be wrapped // in a ExecutionException, and then it is unwrapped again. return get(); } catch (Throwable throwable) { throw rethrow(throwable); } }
v = ex; futures.set(l, new CompletedFuture<T>(getNodeEngine().getSerializationService(), v, getAsyncExecutor())); futures.set(i, new CompletedFuture<T>(getNodeEngine().getSerializationService(), value, getAsyncExecutor())); timeoutNanos -= System.nanoTime() - start;
v = ex; futures.set(l, new CompletedFuture<T>(getNodeEngine().getSerializationService(), v, getAsyncExecutor())); futures.set(i, new CompletedFuture<T>(getNodeEngine().getSerializationService(), value, getAsyncExecutor())); timeoutNanos -= System.nanoTime() - start;
private <T> Future<T> checkSync(ClientInvocationFuture f, String uuid, Address address, boolean preventSync, T defaultValue) { boolean sync = isSyncComputation(preventSync); if (sync) { Object response = retrieveResultFromMessage(f); Executor userExecutor = getContext().getExecutionService().getUserExecutor(); return new CompletedFuture<T>(getSerializationService(), response, userExecutor); } else { return new IExecutorDelegatingFuture<T>(f, getContext(), uuid, defaultValue, SUBMIT_TO_ADDRESS_DECODER, name, address); } }
private <T> Future<T> checkSync(ClientInvocationFuture f, String uuid, Address address, boolean preventSync, T defaultValue) { boolean sync = isSyncComputation(preventSync); if (sync) { Object response = retrieveResultFromMessage(f); Executor userExecutor = getContext().getExecutionService().getUserExecutor(); return new CompletedFuture<T>(getSerializationService(), response, userExecutor); } else { return new IExecutorDelegatingFuture<T>(f, getContext(), uuid, defaultValue, SUBMIT_TO_ADDRESS_DECODER, name, address); } }
private <T> Future<T> checkSync(ClientInvocationFuture f, String uuid, int partitionId, boolean preventSync, T defaultValue) { boolean sync = isSyncComputation(preventSync); if (sync) { Object response = retrieveResultFromMessage(f); Executor userExecutor = getContext().getExecutionService().getUserExecutor(); return new CompletedFuture<T>(getSerializationService(), response, userExecutor); } else { return new IExecutorDelegatingFuture<T>(f, getContext(), uuid, defaultValue, SUBMIT_TO_PARTITION_DECODER, name, partitionId); } }
private <T> Future<T> checkSync(ClientInvocationFuture f, String uuid, int partitionId, boolean preventSync, T defaultValue) { boolean sync = isSyncComputation(preventSync); if (sync) { Object response = retrieveResultFromMessage(f); Executor userExecutor = getContext().getExecutionService().getUserExecutor(); return new CompletedFuture<T>(getSerializationService(), response, userExecutor); } else { return new IExecutorDelegatingFuture<T>(f, getContext(), uuid, defaultValue, SUBMIT_TO_PARTITION_DECODER, name, partitionId); } }
@Override @SuppressWarnings("unchecked") protected InternalCompletableFuture<V> getAsyncInternal(Object key, ExpiryPolicy expiryPolicy, ExecutionCallback<V> callback) { key = serializeKeys ? toData(key) : key; V value = (V) getCachedValue(key, false); if (value != NOT_CACHED) { return new CompletedFuture<V>(getSerializationService(), value, getContext().getExecutionService().getUserExecutor()); } try { Data keyData = toData(key); long reservationId = nearCache.tryReserveForUpdate(key, keyData); GetAsyncCallback getAsyncCallback = new GetAsyncCallback(key, reservationId, callback); return super.getAsyncInternal(keyData, expiryPolicy, getAsyncCallback); } catch (Throwable t) { invalidateNearCache(key); throw rethrow(t); } }
@Override @SuppressWarnings("unchecked") protected InternalCompletableFuture<V> getAsyncInternal(Object key, ExpiryPolicy expiryPolicy, ExecutionCallback<V> callback) { key = serializeKeys ? toData(key) : key; V value = (V) getCachedValue(key, false); if (value != NOT_CACHED) { return new CompletedFuture<V>(getSerializationService(), value, getContext().getExecutionService().getUserExecutor()); } try { Data keyData = toData(key); long reservationId = nearCache.tryReserveForUpdate(key, keyData); GetAsyncCallback getAsyncCallback = new GetAsyncCallback(key, reservationId, callback); return super.getAsyncInternal(keyData, expiryPolicy, getAsyncCallback); } catch (Throwable t) { invalidateNearCache(key); throw rethrow(t); } }
return new CompletedFuture<Object>(null, null, new CallerRunsExecutor());
return new CompletedFuture<Object>(null, null, new CallerRunsExecutor());