com.google.common.util.concurrent.ForwardingListenableFuture Java Examples
The following examples show how to use
com.google.common.util.concurrent.ForwardingListenableFuture.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Futures2.java From Camera2 with Apache License 2.0 | 5 votes |
/** * Creates a new ListenableFuture whose result is set from the supplied * future when it completes. Cancelling the supplied future will also cancel * the returned future, but cancelling the returned future will have no * effect on the supplied future. */ public static <T> ListenableFuture<T> nonCancellationPropagating( final ListenableFuture<T> future) { return new ForwardingListenableFuture.SimpleForwardingListenableFuture<T>(future) { @Override public boolean cancel(boolean mayInterruptIfNecessary) { return false; } }; }
Example #2
Source File: ExecutionScoper.java From yql-plus with Apache License 2.0 | 5 votes |
public <T> ListenableFuture<T> scopeCallbacks(final ListenableFuture<T> callback) { final ScopedObjects scope = getScope(); return new ForwardingListenableFuture<T>() { @Override protected ListenableFuture<T> delegate() { return callback; } @Override public void addListener(Runnable listener, Executor exec) { super.addListener(listener, scope(exec, scope)); } }; }