java.lang.Object
cn.wjybxx.concurrent.PromiseTask<V>
cn.wjybxx.sequential.UniScheduledPromiseTask<V>
- 所有已实现的接口:
cn.wjybxx.base.collection.IndexedElement,CancelTokenListener,IFutureTask<V>,IScheduledFutureTask<V>,ITask,Comparable<Delayed>,Runnable,Delayed,Consumer<Object>
@NotThreadSafe
public final class UniScheduledPromiseTask<V>
extends PromiseTask<V>
implements IScheduledFutureTask<V>, cn.wjybxx.base.collection.IndexedElement, Consumer<Object>, CancelTokenListener
定时任务的Task抽象
与
ScheduledPromiseTask的几个区别:
1. 时间精度为毫秒。
2. 依赖的Executor类型不同。- 作者:
- wjybxx date - 2024/1/8
-
字段概要
从类继承的字段 cn.wjybxx.concurrent.PromiseTask
ctl, ctx, MASK_CLAIMED, MASK_PRIORITY, MASK_SCHEDULE_TYPE, MASK_STARTED, MASK_STOPPED, MASK_TASK_TYPE, MASK_TIMEOUT, MASK_TRIGGERED, MAX_PRIORITY, OFFSET_PRIORITY, OFFSET_SCHEDULE_TYPE, OFFSET_TASK_TYPE, options, promise从接口继承的字段 cn.wjybxx.base.collection.IndexedElement
INDEX_NOT_FOUNT -
方法概要
修饰符和类型方法说明voidvoid该接口只能在EventLoop内调用 -- 且当前任务已弹出队列voidcancelWithoutRemove(int code) 该接口只能在EventLoop内调用 -- 且当前任务已弹出队列voidclear()intcollectionIndex(Object collection) voidcollectionIndex(Object collection, int index) intintcompareToExplicitly(UniScheduledPromiseTask<?> other) future()获取任务绑的Promise - 允许子类重写返回值类型long获取任务下次执行的延迟。longgetId()longint获取任务所属的队列idint获取任务的调度类型boolean关联的任务是否是周期性任务boolean任务是否触发过static UniScheduledPromiseTask<?> ofAction(Runnable action, int options, IScheduledPromise<?> promise, long id, long nextTriggerTime) static UniScheduledPromiseTask<?> ofAction(Consumer<? super IContext> action, IContext ctx, int options, IScheduledPromise<?> promise, long id, long nextTriggerTime) static <V> UniScheduledPromiseTask<V> ofBuilder(ScheduledTaskBuilder<V> builder, IScheduledPromise<V> promise, long id, long tickTime) static <V> UniScheduledPromiseTask<V> ofBuilder(TaskBuilder<V> builder, IScheduledPromise<V> promise, long id, long tickTime) static <V> UniScheduledPromiseTask<V> ofFunction(Callable<? extends V> action, int options, IScheduledPromise<V> promise, long id, long nextTriggerTime) static <V> UniScheduledPromiseTask<V> ofFunction(Function<? super IContext, ? extends V> action, IContext ctx, int options, IScheduledPromise<V> promise, long id, long nextTriggerTime) voidonCancelRequested(ICancelToken cancelToken) void监听取消令牌中的取消信号voidrun()run方法应当使IFutureTask.future()进入完成状态voidsetId(long id) voidsetNextTriggerTime(long nextTriggerTime) voidsetPriority(int priority) void将任务标记为已触发过booleantrigger(long tickTime) 外部确定性触发,不需要回调的方式重新压入队列static longtriggerTime(long delay, TimeUnit timeUnit, long tickTime) 计算任务的触发时间从类继承的方法 cn.wjybxx.concurrent.PromiseTask
getCtlBit, getOptions, getTask, getTaskType, isEnabled, isStarted, ofAction, ofAction, ofBuilder, ofFunction, ofFunction, runTask, runTimeSharing, setCtlBit, setStarted, trySetCancelled, trySetCancelled从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.wjybxx.concurrent.ITask
getOptions
-
方法详细资料
-
ofAction
public static UniScheduledPromiseTask<?> ofAction(Runnable action, int options, IScheduledPromise<?> promise, long id, long nextTriggerTime) -
ofAction
public static UniScheduledPromiseTask<?> ofAction(Consumer<? super IContext> action, IContext ctx, int options, IScheduledPromise<?> promise, long id, long nextTriggerTime) -
ofFunction
public static <V> UniScheduledPromiseTask<V> ofFunction(Callable<? extends V> action, int options, IScheduledPromise<V> promise, long id, long nextTriggerTime) -
ofFunction
public static <V> UniScheduledPromiseTask<V> ofFunction(Function<? super IContext, ? extends V> action, IContext ctx, int options, IScheduledPromise<V> promise, long id, long nextTriggerTime) -
ofBuilder
public static <V> UniScheduledPromiseTask<V> ofBuilder(TaskBuilder<V> builder, IScheduledPromise<V> promise, long id, long tickTime) -
ofBuilder
public static <V> UniScheduledPromiseTask<V> ofBuilder(ScheduledTaskBuilder<V> builder, IScheduledPromise<V> promise, long id, long tickTime) - 参数:
builder- builderpromise- 监听结果的promiseid- 给任务分配的idtickTime- 当前时间(没有单位)- 返回:
- PromiseTask
-
getId
public long getId() -
setId
public void setId(long id) -
getNextTriggerTime
public long getNextTriggerTime() -
setNextTriggerTime
public void setNextTriggerTime(long nextTriggerTime) -
getScheduleType
public int getScheduleType()获取任务的调度类型 -
getPriority
public int getPriority()获取任务所属的队列id -
setPriority
public void setPriority(int priority) - 参数:
priority- 任务的优先级,范围 [0, 255]
-
setTriggered
public void setTriggered()将任务标记为已触发过 -
isTriggered
public boolean isTriggered()任务是否触发过 -
collectionIndex
- 指定者:
collectionIndex在接口中cn.wjybxx.base.collection.IndexedElement
-
collectionIndex
- 指定者:
collectionIndex在接口中cn.wjybxx.base.collection.IndexedElement
-
future
从类复制的说明:PromiseTask获取任务绑的Promise - 允许子类重写返回值类型- 指定者:
future在接口中IFutureTask<V>- 指定者:
future在接口中IScheduledFutureTask<V>- 覆盖:
future在类中PromiseTask<V>
-
isPeriodic
public boolean isPeriodic()从接口复制的说明:IScheduledFutureTask关联的任务是否是周期性任务- 指定者:
isPeriodic在接口中IScheduledFutureTask<V>
-
clear
public void clear()- 覆盖:
clear在类中PromiseTask<V>
-
run
public void run()从接口复制的说明:IFutureTaskrun方法应当使IFutureTask.future()进入完成状态- 指定者:
run在接口中IFutureTask<V>- 指定者:
run在接口中Runnable- 覆盖:
run在类中PromiseTask<V>
-
trigger
public boolean trigger(long tickTime) 外部确定性触发,不需要回调的方式重新压入队列- 返回:
- 如果需要再压入队列则返回true
-
cancelWithoutRemove
public void cancelWithoutRemove()该接口只能在EventLoop内调用 -- 且当前任务已弹出队列 -
cancelWithoutRemove
public void cancelWithoutRemove(int code) 该接口只能在EventLoop内调用 -- 且当前任务已弹出队列 -
registerCancellation
public void registerCancellation()监听取消令牌中的取消信号 -
accept
-
onCancelRequested
- 指定者:
onCancelRequested在接口中CancelTokenListener
-
triggerTime
计算任务的触发时间 -
getDelay
从接口复制的说明:IScheduledFutureTask获取任务下次执行的延迟。 ps:该接口的可见性取决于实现,某些实现不提供即时的可见性,查询可能是不准确的。- 指定者:
getDelay在接口中Delayed- 指定者:
getDelay在接口中IScheduledFutureTask<V>
-
compareTo
- 指定者:
compareTo在接口中Comparable<V>- 指定者:
compareTo在接口中IScheduledFutureTask<V>
-
compareToExplicitly
-