类 SettableListenableFuture<T>
java.lang.Object
cn.taketoday.util.concurrent.SettableListenableFuture<T>
- 类型参数:
T- the result type returned by this Future'sgetmethod
- 所有已实现的接口:
ListenableFuture<T>,Future<T>
A
ListenableFuture whose value can be set via set(Object)
or setException(Throwable). It may also get cancelled.
Inspired by com.google.common.util.concurrent.SettableFuture.
- 从以下版本开始:
- 4.0
- 作者:
- Mattias Severson, Rossen Stoyanchev, Juergen Hoeller
-
嵌套类概要
嵌套类 -
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddCallback(ListenableFutureCallback<? super T> callback) Register the givenListenableFutureCallback.voidaddCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) Java 8 lambda-friendly alternative with success and failure callbacks.booleancancel(boolean mayInterruptIfRunning) Expose thisListenableFutureas a JDKCompletableFuture.get()Retrieve the value.Retrieve the value.protected voidSubclasses can override this method to implement interruption of the future's computation.booleanbooleanisDone()booleanSet the value of this future.booleansetException(Throwable exception) Set the exception of this future.
-
字段详细资料
-
DUMMY_CALLABLE
-
settableTask
-
-
构造器详细资料
-
SettableListenableFuture
public SettableListenableFuture()
-
-
方法详细资料
-
set
Set the value of this future. This method will returntrueif the value was set successfully, orfalseif the future has already been set or cancelled.- 参数:
value- the value that will be set- 返回:
trueif the value was successfully set, elsefalse
-
setException
Set the exception of this future. This method will returntrueif the exception was set successfully, orfalseif the future has already been set or cancelled.- 参数:
exception- the value that will be set- 返回:
trueif the exception was successfully set, elsefalse
-
addCallback
从接口复制的说明:ListenableFutureRegister the givenListenableFutureCallback.- 指定者:
addCallback在接口中ListenableFuture<T>- 参数:
callback- the callback to register
-
addCallback
public void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) 从接口复制的说明:ListenableFutureJava 8 lambda-friendly alternative with success and failure callbacks.- 指定者:
addCallback在接口中ListenableFuture<T>- 参数:
successCallback- the success callbackfailureCallback- the failure callback
-
completable
从接口复制的说明:ListenableFutureExpose thisListenableFutureas a JDKCompletableFuture.- 指定者:
completable在接口中ListenableFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
isCancelled
public boolean isCancelled()- 指定者:
isCancelled在接口中Future<T>
-
isDone
public boolean isDone() -
get
Retrieve the value.This method returns the value if it has been set via
set(Object), throws anExecutionExceptionif an exception has been set viasetException(Throwable), or throws aCancellationExceptionif the future has been cancelled.- 指定者:
get在接口中Future<T>- 返回:
- the value associated with this future
- 抛出:
InterruptedExceptionExecutionException
-
get
@Nullable public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Retrieve the value.This method returns the value if it has been set via
set(Object), throws anExecutionExceptionif an exception has been set viasetException(Throwable), or throws aCancellationExceptionif the future has been cancelled.- 指定者:
get在接口中Future<T>- 参数:
timeout- the maximum time to waitunit- the unit of the timeout argument- 返回:
- the value associated with this future
- 抛出:
InterruptedExceptionExecutionExceptionTimeoutException
-
interruptTask
protected void interruptTask()Subclasses can override this method to implement interruption of the future's computation. The method is invoked automatically by a successful call tocancel(true).The default implementation is empty.
-