active-logic/activelogic-cs

Reset-on-Exit/Reset-on-Crit

Closed this issue · 3 comments

Reset-on-Resume (RoR) is a relatively new feature in Active Logic. Experiments show that Reset-on-Resume is not dependable enough, since it may cause issues when repeating tasks seamlessly (see #37)
Reset-on-Exit is safer, and may be implemented as follows:

roe DoSomething() => `cx() && Wait(0.5) && ... ;  

Or

roe DoSomething(){
    // some preliminary work
    return cx() && Once()?[ task ] ... ;   
}

Above syntax is primarily attractive because it does not require delimiters; other syntaxes are possible; this may come with a few desirable features:

  • RoE decorators fail if no RoE context is provided (runtime check)
  • Stateless control does not require a context, avoiding both syntax and performance overheads.
  • cx() and roe are interdependent, so one cannot accidentally be used without another (compile check)

Draft fix for this. Syntax is conservative:

status Task => roe[ ... ];

Looks thread-safe; likely supports nesting also.

One possible alternative only requires a pseudo-type. Will put this on a branch later, if only for the hell of it.

Looks like both RoR and RoE may be needed to ensure decorators reset when they are expected to.

Dependable solution here is a reset-on-criterion (RoC) (and perhaps later, reset-on-condition) block. Reset-on-exit (RoE) is documented in BT literature, will work in many cases, but I am seeing edge cases where results are incorrect; keeping for now pending further testing/evaluation.

  • reset blocks (RoC, RoE) implemented in 09181f1
  • RoR covers forks missed by reset blocks (already implemented).