类com.google.common.util.concurrent.ForwardingListenableFuture源码实例Demo

下面列出了怎么用com.google.common.util.concurrent.ForwardingListenableFuture的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Camera2   文件: Futures2.java
/**
 * 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;
        }
    };
}
 
源代码2 项目: yql-plus   文件: ExecutionScoper.java
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));
        }
    };
}
 
 类方法
 同包方法