- 所有已实现的接口:
ICompletionStage<V>,IFuture<V>,Future<V>
- 直接已知子类:
ReadOnlyFuture
- 作者:
- wjybxx date - 2024/1/9
-
嵌套类概要
从接口继承的嵌套类/接口 java.util.concurrent.Future
Future.State -
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明返回只读的Future视图, 如果Future是一个提供了写接口的Promise,则返回一个只读的Future视图,返回的实例会在当前Promise进入完成状态时进入完成状态。await()阻塞到任务完成boolean阻塞到任务完成booleanawaitUninterruptibly(long timeout, TimeUnit unit) booleancancel(boolean mayInterruptIfRunning) catching(Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends V> fallback) catching(Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends V> fallback, IContext ctx, int options) 它表示能从从特定的异常中恢复,并返回一个正常结果。catchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends V> fallback) catchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends V> fallback, IContext ctx, int options) <U> IFuture<U> composeApply(BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn) <U> IFuture<U> composeApply(BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn, IContext ctx, int options) 该方法表示在当前Future与返回的Future中插入一个异步操作,构建异步管道 => 这是链式调用的核心API。<U> IFuture<U> composeApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn) <U> IFuture<U> composeApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn, IContext ctx, int options) <U> IFuture<U> composeCall(Function<? super IContext, ? extends ICompletionStage<U>> fn) <U> IFuture<U> composeCall(Function<? super IContext, ? extends ICompletionStage<U>> fn, IContext ctx, int options) <U> IFuture<U> composeCallAsync(Executor executor, Function<? super IContext, ? extends ICompletionStage<U>> fn) <U> IFuture<U> composeCallAsync(Executor executor, Function<? super IContext, ? extends ICompletionStage<U>> fn, IContext ctx, int options) composeCatching(Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback) composeCatching(Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback, IContext ctx, int options) 它表示能从从特定的异常中恢复,并异步返回一个正常结果。composeCatchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback) composeCatchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback, IContext ctx, int options) <U> IFuture<U> composeHandle(TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn) <U> IFuture<U> composeHandle(TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn, IContext ctx, int options) 它表示既能接收任务的正常结果,也可以接收任务异常结果,并异步返回一个运算结果。<U> IFuture<U> composeHandleAsync(Executor executor, TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn) <U> IFuture<U> composeHandleAsync(Executor executor, TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn, IContext ctx, int options) 非阻塞方式获取导致Future失败的原因,不适用被取消的Future; 如果需要获取取消异常,可使用IFuture.exceptionNow(boolean)。exceptionNow(boolean throwIfCancelled) 获取导致任务失败的异常,可获取取消异常executor()任务绑定的Executor 1.对于异步任务,Executor是其执行线程;而对于同步任务,Executor不一定是其执行线程 -- 继承得来的而已。get()getNow()获取关联的计算结果 -- 非阻塞。尝试获取计算结果 -- 非阻塞 如果对应的计算失败,则抛出对应的异常。<U> IFuture<U> handle(TriFunction<? super IContext, ? super V, Throwable, ? extends U> fn) <U> IFuture<U> 该方法表示既能处理当前计算的正常结果,又能处理当前结算的异常结果(可以将异常转换为新的结果),并返回一个新的结果。<U> IFuture<U> handleAsync(Executor executor, TriFunction<? super IContext, ? super V, Throwable, ? extends U> fn) <U> IFuture<U> handleAsync(Executor executor, TriFunction<? super IContext, ? super V, Throwable, ? extends U> fn, IContext ctx, int options) boolean如果future关联的任务在正常完成被取消,则返回true。boolean如果future关联的任务正在执行中,则返回truebooleanisDone()如果future已进入完成状态(成功、失败、被取消),则返回truebooleanisFailed()如果future已进入完成状态,且是失败状态,则返回trueboolean在JDK的约定中,取消和failed是分离的,我们仍保持这样的约定; 但有些时候,我们需要将取消也视为失败的一种,因此需要快捷的方法。boolean如果future关联的任务仍处于等待执行的状态,则返回true (换句话说,如果任务仍在排队,则返回true)boolean如果future已进入完成状态,且是成功完成,则返回true。join()阻塞到任务完成voidonCompleted(BiConsumer<? super IFuture<V>, ? super IContext> action, IContext context) voidonCompleted(BiConsumer<? super IFuture<V>, ? super IContext> action, IContext context, int options) 该接口支持Context参数,可响应取消voidonCompleted(Consumer<? super IFuture<V>> action) voidonCompleted(Consumer<? super IFuture<V>> action, int options) 最原始的Future监听接口 1.voidonCompletedAsync(Executor executor, BiConsumer<? super IFuture<V>, ? super IContext> action, IContext context) voidonCompletedAsync(Executor executor, BiConsumer<? super IFuture<V>, ? super IContext> action, IContext context, int options) voidonCompletedAsync(Executor executor, Consumer<? super IFuture<V>> action) voidonCompletedAsync(Executor executor, Consumer<? super IFuture<V>> action, int options) 非阻塞方式获取Future的执行结果state()已过时。status()future关联的任务的状态thenAccept(BiConsumer<? super IContext, ? super V> action) thenAccept(BiConsumer<? super IContext, ? super V> action, IContext ctx, int options) 该方法返回一个新的Future,它的结果由当前Future驱动。thenAcceptAsync(Executor executor, BiConsumer<? super IContext, ? super V> action) thenAcceptAsync(Executor executor, BiConsumer<? super IContext, ? super V> action, IContext ctx, int options) <U> IFuture<U> thenApply(BiFunction<? super IContext, ? super V, ? extends U> fn) <U> IFuture<U> thenApply(BiFunction<? super IContext, ? super V, ? extends U> fn, IContext ctx, int options) 该方法返回一个新的Future,它的结果由当前Future驱动。<U> IFuture<U> thenApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends U> fn) <U> IFuture<U> thenApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends U> fn, IContext ctx, int options) <U> IFuture<U> <U> IFuture<U> 该方法返回一个新的Future,它的结果由当前Future驱动。<U> IFuture<U> thenCallAsync(Executor executor, Function<? super IContext, ? extends U> fn) <U> IFuture<U> thenCallAsync(Executor executor, Function<? super IContext, ? extends U> fn, IContext ctx, int options) 该方法返回一个新的Future,它的结果由当前Future驱动。thenRunAsync(Executor executor, Consumer<? super IContext> action) thenRunAsync(Executor executor, Consumer<? super IContext> action, IContext ctx, int options) 该接口用于与依赖CompletableFuture的库进行协作toFuture()返回一个Future,保持与这个Stage相同的完成结果。whenComplete(TriConsumer<? super IContext, ? super V, ? super Throwable> action) whenComplete(TriConsumer<? super IContext, ? super V, ? super Throwable> action, IContext ctx, int options) 该方法返回一个新的Future,无论当前Future执行成功还是失败,给定的操作都将执行,且返回的Future始终以相同的结果进入完成状态。whenCompleteAsync(Executor executor, TriConsumer<? super IContext, ? super V, ? super Throwable> action) whenCompleteAsync(Executor executor, TriConsumer<? super IContext, ? super V, ? super Throwable> action, IContext ctx, int options)
-
字段详细资料
-
future
-
-
构造器详细资料
-
ForwardFuture
-
-
方法详细资料
-
toCompletableFuture
从接口复制的说明:ICompletionStage该接口用于与依赖CompletableFuture的库进行协作- 指定者:
toCompletableFuture在接口中ICompletionStage<V>
-
toFuture
从接口复制的说明:ICompletionStage返回一个Future,保持与这个Stage相同的完成结果。 如果这个Stage已经是一个Future,这个方法可以返回这个Stage本身。 可以返回Readonly的Future。- 指定者:
toFuture在接口中ICompletionStage<V>
-
await
从接口复制的说明:IFuture阻塞到任务完成- 指定者:
await在接口中IFuture<V>- 返回:
- this
- 抛出:
InterruptedException
-
awaitUninterruptibly
从接口复制的说明:IFuture阻塞到任务完成- 指定者:
awaitUninterruptibly在接口中IFuture<V>- 返回:
- this
-
executor
从接口复制的说明:ICompletionStage任务绑定的Executor 1.对于异步任务,Executor是其执行线程;而对于同步任务,Executor不一定是其执行线程 -- 继承得来的而已。 2.在添加下游任务时,如果没有显式指定Executor,将继承当前Stage的Executor。 3.Executor主要用于死锁检测,为去除EventLoop的依赖,设计了SingleThreadExecutor接口注意:由于死锁检测并不完全正确,当你需要绕过死锁检测时,可通过添加下游任务重新指定Executor来绕过。
- 指定者:
executor在接口中ICompletionStage<V>
-
asReadonly
从接口复制的说明:IFuture返回只读的Future视图, 如果Future是一个提供了写接口的Promise,则返回一个只读的Future视图,返回的实例会在当前Promise进入完成状态时进入完成状态。1. 一般情况下我们通过接口隔离即可达到读写分离目的,这可以节省开销;在大规模链式调用的情况下,Promise继承Future很有效。 2. 但如果觉得返回Promise实例给任务的发起者不够安全,可创建Promise的只读视图返回给用户 3. 这里不要求返回的必须是同一个实例,每次都可以创建一个新的实例。
- 指定者:
asReadonly在接口中IFuture<V>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) 从接口复制的说明:IFuture -
state
已过时。 -
status
从接口复制的说明:IFuturefuture关联的任务的状态 -
isPending
public boolean isPending()从接口复制的说明:IFuture如果future关联的任务仍处于等待执行的状态,则返回true (换句话说,如果任务仍在排队,则返回true) -
isComputing
public boolean isComputing()从接口复制的说明:IFuture如果future关联的任务正在执行中,则返回true- 指定者:
isComputing在接口中IFuture<V>
-
isDone
public boolean isDone()从接口复制的说明:IFuture如果future已进入完成状态(成功、失败、被取消),则返回true -
isCancelled
public boolean isCancelled()从接口复制的说明:IFuture如果future关联的任务在正常完成被取消,则返回true。- 指定者:
isCancelled在接口中Future<V>- 指定者:
isCancelled在接口中IFuture<V>
-
isSucceeded
public boolean isSucceeded()从接口复制的说明:IFuture如果future已进入完成状态,且是成功完成,则返回true。- 指定者:
isSucceeded在接口中IFuture<V>
-
isFailed
public boolean isFailed()从接口复制的说明:IFuture如果future已进入完成状态,且是失败状态,则返回true -
isFailedOrCancelled
public boolean isFailedOrCancelled()从接口复制的说明:IFuture在JDK的约定中,取消和failed是分离的,我们仍保持这样的约定; 但有些时候,我们需要将取消也视为失败的一种,因此需要快捷的方法。- 指定者:
isFailedOrCancelled在接口中IFuture<V>
-
getNow
从接口复制的说明:IFuture获取关联的计算结果 -- 非阻塞。 如果对应的计算失败,则抛出对应的异常。 如果计算成功,则返回计算结果。 如果计算尚未完成,则返回null。如果future关联的task没有返回值(操作完成返回null),对于这种情况,你可以使用
IFuture.isSucceeded()作为判断任务是否成功执行的更好选择。 -
getNow
从接口复制的说明:IFuture尝试获取计算结果 -- 非阻塞 如果对应的计算失败,则抛出对应的异常。 如果计算成功,则返回计算结果。 如果计算尚未完成,则返回给定值。 -
resultNow
从接口复制的说明:IFuture非阻塞方式获取Future的执行结果 -
exceptionNow
从接口复制的说明:IFuture非阻塞方式获取导致Future失败的原因,不适用被取消的Future; 如果需要获取取消异常,可使用IFuture.exceptionNow(boolean)。- 指定者:
exceptionNow在接口中Future<V>- 指定者:
exceptionNow在接口中IFuture<V>
-
exceptionNow
从接口复制的说明:IFuture获取导致任务失败的异常,可获取取消异常- 指定者:
exceptionNow在接口中IFuture<V>- 参数:
throwIfCancelled- 任务取消的状态下是否抛出状态异常
-
get
从接口复制的说明:IFuture- 指定者:
get在接口中Future<V>- 指定者:
get在接口中IFuture<V>- 抛出:
InterruptedExceptionExecutionException
-
get
public V get(long timeout, @Nonnull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException 从接口复制的说明:IFuture- 指定者:
get在接口中Future<V>- 指定者:
get在接口中IFuture<V>- 抛出:
InterruptedExceptionExecutionExceptionTimeoutException
-
await
- 指定者:
await在接口中IFuture<V>- 返回:
- 如果任务在这期间进入了完成状态,则返回true
- 抛出:
InterruptedException
-
awaitUninterruptibly
- 指定者:
awaitUninterruptibly在接口中IFuture<V>- 返回:
- 如果任务在这期间进入了完成状态,则返回true
-
join
从接口复制的说明:IFuture阻塞到任务完成 -
onCompleted
public void onCompleted(BiConsumer<? super IFuture<V>, ? super IContext> action, @Nonnull IContext context, int options) 从接口复制的说明:IFuture该接口支持Context参数,可响应取消- 指定者:
onCompleted在接口中IFuture<V>
-
onCompleted
public void onCompleted(BiConsumer<? super IFuture<V>, ? super IContext> action, @Nonnull IContext context) - 指定者:
onCompleted在接口中IFuture<V>
-
onCompletedAsync
public void onCompletedAsync(Executor executor, BiConsumer<? super IFuture<V>, ? super IContext> action, @Nonnull IContext context) - 指定者:
onCompletedAsync在接口中IFuture<V>
-
onCompletedAsync
public void onCompletedAsync(Executor executor, BiConsumer<? super IFuture<V>, ? super IContext> action, @Nonnull IContext context, int options) - 指定者:
onCompletedAsync在接口中IFuture<V>
-
onCompleted
从接口复制的说明:IFuture最原始的Future监听接口 1. 给定的Action将在Future关联的任务完成时执行,无论成功或失败都将执行。 2. 该操作不是链式调用,不会继承上下文!不会继承上下文!不会继承上下文! 3. 通常只用于一些特殊功能 -- 比如大规模监听时减少开销。 4. 暂不设定返回会为this,以免以后需要封装用于删除的句柄等- 指定者:
onCompleted在接口中IFuture<V>- 参数:
options- 调度选项,可为0
-
onCompleted
- 指定者:
onCompleted在接口中IFuture<V>
-
onCompletedAsync
- 指定者:
onCompletedAsync在接口中IFuture<V>
-
onCompletedAsync
- 指定者:
onCompletedAsync在接口中IFuture<V>
-
composeApply
public <U> IFuture<U> composeApply(BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法表示在当前Future与返回的Future中插入一个异步操作,构建异步管道 => 这是链式调用的核心API。 该方法对应我们日常流中使用的Stream.flatMap(Function)操作。该方法返回一个新的
Future,它的最终结果与指定的Function返回的Future结果相同。 如果当前Future执行失败,则返回的Future将以相同的原因失败,且指定的动作不会执行。 如果当前Future执行成功,则当前Future的执行结果将作为指定操作的执行参数。- 指定者:
composeApply在接口中ICompletionStage<V>- 指定者:
composeApply在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
composeApply
public <U> IFuture<U> composeApply(BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn) - 指定者:
composeApply在接口中ICompletionStage<V>- 指定者:
composeApply在接口中IFuture<V>- 参数:
fn- 的ctx参数为IContext.NONE
-
composeApplyAsync
public <U> IFuture<U> composeApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn) - 指定者:
composeApplyAsync在接口中ICompletionStage<V>- 指定者:
composeApplyAsync在接口中IFuture<V>
-
composeApplyAsync
public <U> IFuture<U> composeApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends ICompletionStage<U>> fn, @Nullable IContext ctx, int options) - 指定者:
composeApplyAsync在接口中ICompletionStage<V>- 指定者:
composeApplyAsync在接口中IFuture<V>
-
composeCall
public <U> IFuture<U> composeCall(Function<? super IContext, ? extends ICompletionStage<U>> fn, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法表示在当前Future与返回的Future中插入一个异步操作,构建异步管道 该方法对应我们日常流中使用的Stream.flatMap(Function)操作。该方法返回一个新的
Future,它的最终结果与指定的Function返回的Future结果相同。 如果当前Future执行失败,则返回的Future将以相同的原因失败,且指定的动作不会执行。 如果当前Future执行成功,则当前Future的执行结果将作为指定操作的执行参数。CompletionStage.thenCompose(Function)ICompletionStage.composeApply(BiFunction)- 指定者:
composeCall在接口中ICompletionStage<V>- 指定者:
composeCall在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
composeCall
- 指定者:
composeCall在接口中ICompletionStage<V>- 指定者:
composeCall在接口中IFuture<V>
-
composeCallAsync
public <U> IFuture<U> composeCallAsync(Executor executor, Function<? super IContext, ? extends ICompletionStage<U>> fn) - 指定者:
composeCallAsync在接口中ICompletionStage<V>- 指定者:
composeCallAsync在接口中IFuture<V>
-
composeCallAsync
public <U> IFuture<U> composeCallAsync(Executor executor, Function<? super IContext, ? extends ICompletionStage<U>> fn, @Nullable IContext ctx, int options) - 指定者:
composeCallAsync在接口中ICompletionStage<V>- 指定者:
composeCallAsync在接口中IFuture<V>
-
composeCatching
public <X extends Throwable> IFuture<V> composeCatching(Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage它表示能从从特定的异常中恢复,并异步返回一个正常结果。该方法返回一个新的
Future,它的结果由当前Future驱动。 如果当前Future正常完成,则给定的动作不会执行,且返回的Future使用相同的结果值进入完成状态。 如果当前Future执行失败,则其异常信息将作为指定操作的执行参数,返回的Future的结果取决于指定操作的执行结果。- 指定者:
composeCatching在接口中ICompletionStage<V>- 指定者:
composeCatching在接口中IFuture<V>- 参数:
fallback- 恢复函数ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
composeCatching
public <X extends Throwable> IFuture<V> composeCatching(Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback) - 指定者:
composeCatching在接口中ICompletionStage<V>- 指定者:
composeCatching在接口中IFuture<V>
-
composeCatchingAsync
public <X extends Throwable> IFuture<V> composeCatchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback) - 指定者:
composeCatchingAsync在接口中ICompletionStage<V>- 指定者:
composeCatchingAsync在接口中IFuture<V>
-
composeCatchingAsync
public <X extends Throwable> IFuture<V> composeCatchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends ICompletionStage<V>> fallback, @Nullable IContext ctx, int options) - 指定者:
composeCatchingAsync在接口中ICompletionStage<V>- 指定者:
composeCatchingAsync在接口中IFuture<V>
-
composeHandle
public <U> IFuture<U> composeHandle(TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage它表示既能接收任务的正常结果,也可以接收任务异常结果,并异步返回一个运算结果。该方法返回一个新的
Future,它的结果由当前Future驱动。 不论当前Future成功还是失败,都将执行给定的操作,返回的Future的结果取决于指定操作的执行结果。- 指定者:
composeHandle在接口中ICompletionStage<V>- 指定者:
composeHandle在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
composeHandle
public <U> IFuture<U> composeHandle(TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn) - 指定者:
composeHandle在接口中ICompletionStage<V>- 指定者:
composeHandle在接口中IFuture<V>
-
composeHandleAsync
public <U> IFuture<U> composeHandleAsync(Executor executor, TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn) - 指定者:
composeHandleAsync在接口中ICompletionStage<V>- 指定者:
composeHandleAsync在接口中IFuture<V>
-
composeHandleAsync
public <U> IFuture<U> composeHandleAsync(Executor executor, TriFunction<? super IContext, ? super V, ? super Throwable, ? extends ICompletionStage<U>> fn, @Nullable IContext ctx, int options) - 指定者:
composeHandleAsync在接口中ICompletionStage<V>- 指定者:
composeHandleAsync在接口中IFuture<V>
-
thenApply
public <U> IFuture<U> thenApply(BiFunction<? super IContext, ? super V, ? extends U> fn, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法返回一个新的Future,它的结果由当前Future驱动。 如果当前Future执行失败,则返回的Future将以相同的原因失败,且指定的动作不会执行。 如果当前Future执行成功,则当前Future的执行结果将作为指定操作的执行参数,返回的Future的结果取决于指定操作的执行结果。- 指定者:
thenApply在接口中ICompletionStage<V>- 指定者:
thenApply在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
thenApply
-
thenApplyAsync
public <U> IFuture<U> thenApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends U> fn) - 指定者:
thenApplyAsync在接口中ICompletionStage<V>- 指定者:
thenApplyAsync在接口中IFuture<V>
-
thenApplyAsync
public <U> IFuture<U> thenApplyAsync(Executor executor, BiFunction<? super IContext, ? super V, ? extends U> fn, @Nullable IContext ctx, int options) - 指定者:
thenApplyAsync在接口中ICompletionStage<V>- 指定者:
thenApplyAsync在接口中IFuture<V>
-
thenAccept
public IFuture<Void> thenAccept(BiConsumer<? super IContext, ? super V> action, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法返回一个新的Future,它的结果由当前Future驱动。 如果当前Future执行失败,则返回的Future将以相同的原因失败,且指定的动作不会执行。 如果当前Future执行成功,则当前Future的执行结果将作为指定操作的执行参数,返回的Future的结果取决于指定操作的执行结果。- 指定者:
thenAccept在接口中ICompletionStage<V>- 指定者:
thenAccept在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
thenAccept
- 指定者:
thenAccept在接口中ICompletionStage<V>- 指定者:
thenAccept在接口中IFuture<V>
-
thenAcceptAsync
public IFuture<Void> thenAcceptAsync(Executor executor, BiConsumer<? super IContext, ? super V> action) - 指定者:
thenAcceptAsync在接口中ICompletionStage<V>- 指定者:
thenAcceptAsync在接口中IFuture<V>
-
thenAcceptAsync
public IFuture<Void> thenAcceptAsync(Executor executor, BiConsumer<? super IContext, ? super V> action, @Nullable IContext ctx, int options) - 指定者:
thenAcceptAsync在接口中ICompletionStage<V>- 指定者:
thenAcceptAsync在接口中IFuture<V>
-
thenCall
public <U> IFuture<U> thenCall(Function<? super IContext, ? extends U> fn, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法返回一个新的Future,它的结果由当前Future驱动。 如果当前Future执行失败,则返回的Future将以相同的原因失败,且指定的动作不会执行。 如果当前Future执行成功,则执行给定的操作,返回的Future的结果取决于指定操作的执行结果。- 指定者:
thenCall在接口中ICompletionStage<V>- 指定者:
thenCall在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
thenCall
-
thenCallAsync
- 指定者:
thenCallAsync在接口中ICompletionStage<V>- 指定者:
thenCallAsync在接口中IFuture<V>
-
thenCallAsync
public <U> IFuture<U> thenCallAsync(Executor executor, Function<? super IContext, ? extends U> fn, @Nullable IContext ctx, int options) - 指定者:
thenCallAsync在接口中ICompletionStage<V>- 指定者:
thenCallAsync在接口中IFuture<V>
-
thenRun
public IFuture<Void> thenRun(Consumer<? super IContext> action, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法返回一个新的Future,它的结果由当前Future驱动。 如果当前Future执行失败,则返回的Future将以相同的原因失败,且指定的动作不会执行。 如果当前Future执行成功,则执行给定的操作,返回的Future的结果取决于指定操作的执行结果。- 指定者:
thenRun在接口中ICompletionStage<V>- 指定者:
thenRun在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
thenRun
-
thenRunAsync
- 指定者:
thenRunAsync在接口中ICompletionStage<V>- 指定者:
thenRunAsync在接口中IFuture<V>
-
thenRunAsync
public IFuture<Void> thenRunAsync(Executor executor, Consumer<? super IContext> action, @Nullable IContext ctx, int options) - 指定者:
thenRunAsync在接口中ICompletionStage<V>- 指定者:
thenRunAsync在接口中IFuture<V>
-
catching
public <X extends Throwable> IFuture<V> catching(Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends V> fallback, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage它表示能从从特定的异常中恢复,并返回一个正常结果。该方法返回一个新的
Future,它的结果由当前Future驱动。 如果当前Future正常完成,则给定的动作不会执行,且返回的Future使用相同的结果值进入完成状态。 如果当前Future执行失败,则其异常信息将作为指定操作的执行参数,返回的Future的结果取决于指定操作的执行结果。不得不说JDK的
CompletionStage.exceptionally(Function)这个名字太差劲了,实现的也不够好,因此我们不使用它, 这里选择了Guava中的实现- 指定者:
catching在接口中ICompletionStage<V>- 指定者:
catching在接口中IFuture<V>- 参数:
exceptionType- 能处理的异常类型fallback- 异常恢复函数ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
catching
-
catchingAsync
public <X extends Throwable> IFuture<V> catchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends V> fallback) - 指定者:
catchingAsync在接口中ICompletionStage<V>- 指定者:
catchingAsync在接口中IFuture<V>
-
catchingAsync
public <X extends Throwable> IFuture<V> catchingAsync(Executor executor, Class<X> exceptionType, BiFunction<? super IContext, ? super X, ? extends V> fallback, @Nullable IContext ctx, int options) - 指定者:
catchingAsync在接口中ICompletionStage<V>- 指定者:
catchingAsync在接口中IFuture<V>
-
handle
public <U> IFuture<U> handle(TriFunction<? super IContext, ? super V, Throwable, ? extends U> fn, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法表示既能处理当前计算的正常结果,又能处理当前结算的异常结果(可以将异常转换为新的结果),并返回一个新的结果。该方法返回一个新的
Future,无论当前Future执行成功还是失败,给定的操作都将执行。 如果当前Future执行成功,而指定的动作出现异常,则返回的Future以该异常完成。 如果当前Future执行失败,且指定的动作出现异常,则返回的Future以新抛出的异常进入完成状态。- 指定者:
handle在接口中ICompletionStage<V>- 指定者:
handle在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
handle
-
handleAsync
public <U> IFuture<U> handleAsync(Executor executor, TriFunction<? super IContext, ? super V, Throwable, ? extends U> fn) - 指定者:
handleAsync在接口中ICompletionStage<V>- 指定者:
handleAsync在接口中IFuture<V>
-
handleAsync
public <U> IFuture<U> handleAsync(Executor executor, TriFunction<? super IContext, ? super V, Throwable, ? extends U> fn, @Nullable IContext ctx, int options) - 指定者:
handleAsync在接口中ICompletionStage<V>- 指定者:
handleAsync在接口中IFuture<V>
-
whenComplete
public IFuture<V> whenComplete(TriConsumer<? super IContext, ? super V, ? super Throwable> action, @Nullable IContext ctx, int options) 从接口复制的说明:ICompletionStage该方法返回一个新的Future,无论当前Future执行成功还是失败,给定的操作都将执行,且返回的Future始终以相同的结果进入完成状态。 与方法ICompletionStage.handle(TriFunction)不同,此方法不是为转换完成结果而设计的,因此提供的操作不应引发异常。
1.如果action出现了异常,则仅仅记录一个日志,不向下传播(这里与JDK实现不同) -- 应当避免抛出异常。 2.如果用户主动取消了返回的Future,或者用于异步执行的Executor已关闭,则不会以相同的结果进入完成状态。- 指定者:
whenComplete在接口中ICompletionStage<V>- 指定者:
whenComplete在接口中IFuture<V>- 参数:
ctx- 上下文,如果为null,则替换为NONEoptions- 调度选项,默认使用0即可,可参考TaskOption
-
whenComplete
- 指定者:
whenComplete在接口中ICompletionStage<V>- 指定者:
whenComplete在接口中IFuture<V>
-
whenCompleteAsync
public IFuture<V> whenCompleteAsync(Executor executor, TriConsumer<? super IContext, ? super V, ? super Throwable> action) - 指定者:
whenCompleteAsync在接口中ICompletionStage<V>- 指定者:
whenCompleteAsync在接口中IFuture<V>
-
whenCompleteAsync
public IFuture<V> whenCompleteAsync(Executor executor, TriConsumer<? super IContext, ? super V, ? super Throwable> action, @Nullable IContext ctx, int options) - 指定者:
whenCompleteAsync在接口中ICompletionStage<V>- 指定者:
whenCompleteAsync在接口中IFuture<V>
-