接口 SettableFuture<V>
- 所有超级接口:
Future<V>,ListenableFuture<V>
- 所有已知子接口:
ProgressiveFuture<V>
Special
ListenableFuture which is writable.- 从以下版本开始:
- 4.0 2024/2/26 15:57
- 作者:
- Harry Yang
-
方法概要
修饰符和类型方法说明addListener(FutureListener<? extends ListenableFuture<V>> listener) Adds the specified listener to this future.default SettableFuture<V>addListener(SuccessCallback<V> successCallback, FailureCallback failureCallback) Java 8 lambda-friendly alternative with success and failure callbacks.addListeners(FutureListener<? extends ListenableFuture<V>>... listeners) Adds the specified listeners to this future.await()Waits for this future to be completed.Waits for this future to be completed without interruption.default SettableFuture<V>onFailure(FailureCallback failureCallback) Java 8 lambda-friendly alternative with failure callbacks.default SettableFuture<V>onSuccess(SuccessCallback<V> successCallback) Java 8 lambda-friendly alternative with success callbacks.removeListener(FutureListener<? extends ListenableFuture<V>> listener) Removes the first occurrence of the specified listener from this future.removeListeners(FutureListener<? extends ListenableFuture<V>>... listeners) Removes the first occurrence for each of the listeners from this future.setFailure(Throwable cause) Marks this future as a failure and notifies all listeners.setSuccess(V result) Marks this future as a success and notifies all listeners.booleanMake this future impossible to cancel.sync()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.Waits for this future until it is done, and rethrows the cause of the failure if this future failed.booleantryFailure(Throwable cause) Marks this future as a failure and notifies all listeners.booleantrySuccess(V result) Marks this future as a success and notifies all listeners.从接口继承的方法 java.util.concurrent.Future
get, get, isCancelled, isDone从接口继承的方法 cn.taketoday.util.concurrent.ListenableFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, completable, getCause, getNow, isCancellable, isSuccess, obtain
-
方法详细资料
-
setSuccess
Marks this future as a success and notifies all listeners. If it is success or failed already it will throw anIllegalStateException. -
trySuccess
Marks this future as a success and notifies all listeners.- 返回:
trueif and only if successfully marked this future as a success. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
setFailure
Marks this future as a failure and notifies all listeners. If it is success or failed already it will throw anIllegalStateException. -
tryFailure
Marks this future as a failure and notifies all listeners.- 返回:
trueif and only if successfully marked this future as a failure. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
setUncancellable
boolean setUncancellable()Make this future impossible to cancel.- 返回:
trueif and only if successfully marked this future as uncancellable or it is already done without being cancelled.falseif this future has been cancelled already.
-
addListener
default SettableFuture<V> addListener(SuccessCallback<V> successCallback, @Nullable FailureCallback failureCallback) 从接口复制的说明:ListenableFutureJava 8 lambda-friendly alternative with success and failure callbacks.- 指定者:
addListener在接口中ListenableFuture<V>- 参数:
successCallback- the success callbackfailureCallback- the failure callback
-
onSuccess
从接口复制的说明:ListenableFutureJava 8 lambda-friendly alternative with success callbacks.- 指定者:
onSuccess在接口中ListenableFuture<V>- 参数:
successCallback- the success callback
-
onFailure
从接口复制的说明:ListenableFutureJava 8 lambda-friendly alternative with failure callbacks.- 指定者:
onFailure在接口中ListenableFuture<V>- 参数:
failureCallback- the failure callback
-
addListener
从接口复制的说明:ListenableFutureAdds the specified listener to this future.The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.
- 指定者:
addListener在接口中ListenableFuture<V>
-
addListeners
从接口复制的说明:ListenableFutureAdds the specified listeners to this future.The specified listeners are notified when this future is done. If this future is already completed, the specified listeners are notified immediately.
- 指定者:
addListeners在接口中ListenableFuture<V>
-
removeListener
从接口复制的说明:ListenableFutureRemoves the first occurrence of the specified listener from this future.The specified listener is no longer notified when this future is done. If the specified listener is not associated with this future, this method does nothing and returns silently.
- 指定者:
removeListener在接口中ListenableFuture<V>
-
removeListeners
从接口复制的说明:ListenableFutureRemoves the first occurrence for each of the listeners from this future.The specified listeners are no longer notified when this future is done. If the specified listeners are not associated with this future, this method does nothing and returns silently.
- 指定者:
removeListeners在接口中ListenableFuture<V>
-
await
从接口复制的说明:ListenableFutureWaits for this future to be completed.- 指定者:
await在接口中ListenableFuture<V>- 抛出:
InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
SettableFuture<V> awaitUninterruptibly()从接口复制的说明:ListenableFutureWaits for this future to be completed without interruption. This method catches anInterruptedExceptionand discards it silently.- 指定者:
awaitUninterruptibly在接口中ListenableFuture<V>
-
sync
从接口复制的说明:ListenableFutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- 指定者:
sync在接口中ListenableFuture<V>- 抛出:
InterruptedException
-
syncUninterruptibly
SettableFuture<V> syncUninterruptibly()从接口复制的说明:ListenableFutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- 指定者:
syncUninterruptibly在接口中ListenableFuture<V>
-