java.lang.Object
cn.wjybxx.concurrent.ReadonlyCancelToken
- 所有已实现的接口:
ICancelToken
- 作者:
- wjybxx date - 2024/1/9
-
字段概要
从接口继承的字段 cn.wjybxx.concurrent.ICancelToken
NONE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明返回一个只读的ICancelToken试图,返回的实例会在当前Token被取消时取消。boolean当前token是否可以进入取消状态int取消码 1.void检测取消信号 如果收到取消信号,则抛出CancellationExceptionintdegree()取消的紧急程度boolean是否已收到取消信号 任务的执行者将持有该令牌,在调度任务前会检测取消信号;如果任务已经开始,则由用户的任务自身检测取消和中断信号。boolean取消指令中是否要求了中断线程boolean取消指令中是否要求了无需删除intreason()取消的原因 (1~10为底层使用,10以上为用户自定义)TthenAccept(BiConsumer<? super ICancelToken, Object> action, Object ctx) thenAccept(BiConsumer<? super ICancelToken, Object> action, Object ctx, int options) thenAccept(Consumer<? super ICancelToken> action) thenAccept(Consumer<? super ICancelToken> action, int options) 添加的action将在Context收到取消信号时执行 1.如果已收到取消请求,则给定的action会立即执行。thenAcceptAsync(Executor executor, BiConsumer<? super ICancelToken, Object> action, Object ctx) thenAcceptAsync(Executor executor, BiConsumer<? super ICancelToken, Object> action, Object ctx, int options) thenAcceptAsync(Executor executor, Consumer<? super ICancelToken> action) thenAcceptAsync(Executor executor, Consumer<? super ICancelToken> action, int options) thenNotify(CancelTokenListener action) thenNotify(CancelTokenListener action, int options) 添加一个特定类型的监听器 (用于特殊需求时避免额外的闭包 - task经常需要监听取消令牌)thenNotifyAsync(Executor executor, CancelTokenListener action) thenNotifyAsync(Executor executor, CancelTokenListener action, int options) thenRunAsync(Executor executor, Runnable action) thenRunAsync(Executor executor, Runnable action, int options) thenRunAsync(Executor executor, Consumer<Object> action, Object ctx) thenRunAsync(Executor executor, Consumer<Object> action, Object ctx, int options) thenTransferTo(ICancelTokenSource child) thenTransferTo(ICancelTokenSource child, int options) 该接口用于方便构建子上下文 1.子token会在当前token进入取消状态时被取消 2.该接口本质是一个快捷方法,但允许子类优化thenTransferToAsync(Executor executor, ICancelTokenSource child) thenTransferToAsync(Executor executor, ICancelTokenSource child, int options)
-
构造器详细资料
-
ReadonlyCancelToken
-
-
方法详细资料
-
asReadonly
从接口复制的说明:ICancelToken返回一个只读的ICancelToken试图,返回的实例会在当前Token被取消时取消。 其作用类似IFuture.asReadonly()- 指定者:
asReadonly在接口中ICancelToken
-
canBeCancelled
public boolean canBeCancelled()从接口复制的说明:ICancelToken当前token是否可以进入取消状态- 指定者:
canBeCancelled在接口中ICancelToken- 返回:
- 如果当前token可以进入取消状态则返回true
-
cancelCode
public int cancelCode()从接口复制的说明:ICancelToken取消码 1. 按bit位存储信息,包括是否请求中断,是否超时,紧急程度等 2. 低20位为取消原因;高12位为特殊信息CancelCodes.MASK_REASON3. 不为0表示已发起取消请求 4. 取消时至少赋值一个信息,reason通常应该赋值- 指定者:
cancelCode在接口中ICancelToken
-
isCancelling
public boolean isCancelling()从接口复制的说明:ICancelToken是否已收到取消信号 任务的执行者将持有该令牌,在调度任务前会检测取消信号;如果任务已经开始,则由用户的任务自身检测取消和中断信号。- 指定者:
isCancelling在接口中ICancelToken
-
reason
public int reason()从接口复制的说明:ICancelToken取消的原因 (1~10为底层使用,10以上为用户自定义)T- 指定者:
reason在接口中ICancelToken
-
degree
public int degree()从接口复制的说明:ICancelToken取消的紧急程度- 指定者:
degree在接口中ICancelToken
-
isInterruptible
public boolean isInterruptible()从接口复制的说明:ICancelToken取消指令中是否要求了中断线程- 指定者:
isInterruptible在接口中ICancelToken
-
isWithoutRemove
public boolean isWithoutRemove()从接口复制的说明:ICancelToken取消指令中是否要求了无需删除- 指定者:
isWithoutRemove在接口中ICancelToken
-
checkCancel
public void checkCancel()从接口复制的说明:ICancelToken检测取消信号 如果收到取消信号,则抛出CancellationException- 指定者:
checkCancel在接口中ICancelToken
-
thenAccept
从接口复制的说明:ICancelToken添加的action将在Context收到取消信号时执行 1.如果已收到取消请求,则给定的action会立即执行。 2.如果尚未收到取消请求,则给定action会在收到请求时执行。- 指定者:
thenAccept在接口中ICancelToken
-
thenAccept
- 指定者:
thenAccept在接口中ICancelToken
-
thenAcceptAsync
- 指定者:
thenAcceptAsync在接口中ICancelToken
-
thenAcceptAsync
public IRegistration thenAcceptAsync(Executor executor, Consumer<? super ICancelToken> action, int options) - 指定者:
thenAcceptAsync在接口中ICancelToken
-
thenAccept
public IRegistration thenAccept(BiConsumer<? super ICancelToken, Object> action, Object ctx, int options) - 指定者:
thenAccept在接口中ICancelToken
-
thenAccept
- 指定者:
thenAccept在接口中ICancelToken
-
thenAcceptAsync
public IRegistration thenAcceptAsync(Executor executor, BiConsumer<? super ICancelToken, Object> action, Object ctx) - 指定者:
thenAcceptAsync在接口中ICancelToken
-
thenAcceptAsync
public IRegistration thenAcceptAsync(Executor executor, BiConsumer<? super ICancelToken, Object> action, Object ctx, int options) - 指定者:
thenAcceptAsync在接口中ICancelToken
-
thenRun
- 指定者:
thenRun在接口中ICancelToken
-
thenRun
- 指定者:
thenRun在接口中ICancelToken
-
thenRunAsync
- 指定者:
thenRunAsync在接口中ICancelToken
-
thenRunAsync
- 指定者:
thenRunAsync在接口中ICancelToken
-
thenRun
- 指定者:
thenRun在接口中ICancelToken
-
thenRun
- 指定者:
thenRun在接口中ICancelToken
-
thenRunAsync
- 指定者:
thenRunAsync在接口中ICancelToken
-
thenRunAsync
public IRegistration thenRunAsync(Executor executor, Consumer<Object> action, Object ctx, int options) - 指定者:
thenRunAsync在接口中ICancelToken
-
thenNotify
从接口复制的说明:ICancelToken添加一个特定类型的监听器 (用于特殊需求时避免额外的闭包 - task经常需要监听取消令牌)- 指定者:
thenNotify在接口中ICancelToken
-
thenNotify
- 指定者:
thenNotify在接口中ICancelToken
-
thenNotifyAsync
- 指定者:
thenNotifyAsync在接口中ICancelToken
-
thenNotifyAsync
- 指定者:
thenNotifyAsync在接口中ICancelToken
-
thenTransferTo
从接口复制的说明:ICancelToken该接口用于方便构建子上下文 1.子token会在当前token进入取消状态时被取消 2.该接口本质是一个快捷方法,但允许子类优化注意:在Future体系下,child是上游任务;而在行为树这类体系下,child是下游任务。
- 指定者:
thenTransferTo在接口中ICancelToken- 参数:
child- 接收结果的子tokenoptions- 调度选项
-
thenTransferTo
- 指定者:
thenTransferTo在接口中ICancelToken
-
thenTransferToAsync
- 指定者:
thenTransferToAsync在接口中ICancelToken
-
thenTransferToAsync
- 指定者:
thenTransferToAsync在接口中ICancelToken
-