java.lang.Object
cn.wjybxx.btree.Task<T>
cn.wjybxx.btree.Decorator<T>
cn.wjybxx.btree.decorator.LoopDecorator<T>
- 所有已实现的接口:
ICancelTokenListener
- 直接已知子类:
Repeat,UntilCond,UntilFail,UntilSuccess
循环节点抽象
注意:该模板类默认支持了尾递归优化,如果子类没有重写execute()方法,
那么在Task.onChildCompleted(Task)方法中还需要判断是否启用了尾递归优化,
如果启用了尾递归优化,也需要调用Task.template_execute(boolean)方法。
- 作者:
- wjybxx date - 2023/11/26
-
字段概要
字段从类继承的字段 cn.wjybxx.btree.Decorator
child, inlineHelper从类继承的字段 cn.wjybxx.btree.Task
blackboard, cancelToken, flags, logger, MASK_AUTO_LISTEN_CANCEL, MASK_AUTO_RESET_CHILDREN, MASK_BLACKBOARD_PER_CHILD, MASK_CANCEL_TOKEN_PER_CHILD, MASK_CONTROL_FLOW_OPTIONS, MASK_DISABLE_CHECK_CANCEL, MASK_INVERTED_GUARD, MASK_SLOW_START, MASK_TAIL_CALL_RECURSION, sharedProps -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected void模板类不重写enter方法,只有数据初始化逻辑protected voidexecute()Task的心跳方法,在Task进入完成状态之前会反复执行。intprotected boolean是否还有下一次循环voidsetMaxLoop(int maxLoop) 从类继承的方法 cn.wjybxx.btree.Decorator
addChildImpl, childStream, exit, getChild, getChild, getChildCount, getInlineHelper, indexChild, onChildRunning, onEventImpl, removeChildImpl, resetForRestart, setChild, setChildImpl, stopRunningChildren从类继承的方法 cn.wjybxx.btree.Task
addChild, canHandleEvent, checkCancel, enter, exportControlFlowOptions, getBlackboard, getCancelToken, getControl, getControlData, getControlFlowOptions, getEnterFrame, getEntity, getExitFrame, getFlags, getGuard, getNormalizedStatus, getPrevStatus, getReentryId, getRunFrames, getSharedProps, getStatus, getTaskEntry, isActiveInHierarchy, isActiveSelf, isAutoListenCancel, isAutoResetChildren, isBlackboardPerChild, isCancelled, isCancelTokenPerChild, isCompleted, isDisableCheckCancel, isExecuteTriggeredByEnter, isExecuting, isExited, isExitTriggeredByStop, isFailed, isFailedOrCancelled, isInlinable, isInvertedGuard, isRunning, isSlowStart, isStillborn, isSucceeded, isTailRecursion, onCancelRequested, onChildCompleted, onEvent, refreshActiveInHierarchy, refreshChildrenActiveInHierarchy, registerCancelListener, removeAllChild, removeChild, removeChild, resetChildrenForRestart, resetForRestart, setActive, setAutoListenCancel, setAutoResetChildren, setBlackboard, setBlackboardPerChild, setCancelled, setCancelToken, setCancelTokenPerChild, setChild, setChildCancelToken, setCompleted, setControl, setControlData, setDisableCheckCancel, setEnterFrame, setExitFrame, setFailed, setFlags, setGuard, setGuardFailed, setInvertedGuard, setPrevStatus, setSharedProps, setSlowStart, setSuccess, setTailRecursion, stop, stop, template_checkGuard, template_execute, template_runChild, template_runChildDirectly, template_runHook, template_runHookDirectly, template_runInlinedChild, unsetChildCancelToken, unsetControl
-
字段详细资料
-
maxLoop
protected int maxLoop最大循环次数,超过次数直接失败;大于0有效 -
curLoop
protected transient int curLoop
-
-
构造器详细资料
-
LoopDecorator
public LoopDecorator() -
LoopDecorator
-
-
方法详细资料
-
beforeEnter
protected void beforeEnter()从类复制的说明:Decorator模板类不重写enter方法,只有数据初始化逻辑- 覆盖:
beforeEnter在类中Decorator<T>
-
execute
protected void execute()从类复制的说明:TaskTask的心跳方法,在Task进入完成状态之前会反复执行。 1.可以根据Task.isExecuteTriggeredByEnter()判断是否是与Task.enter(int)连续执行的。 2.运行中可通过Task.setSuccess()、Task.setFailed(int)、Task.setCancelled()将自己更新为完成状态。 3.不建议直接调用该方法,而是通过模板方法Task.template_execute(boolean)运行。 -
hasNextLoop
protected boolean hasNextLoop()是否还有下一次循环 -
getMaxLoop
public int getMaxLoop() -
setMaxLoop
public void setMaxLoop(int maxLoop)
-