Cancellation Token
Tokens are extremely lightweight and easy to grok, their power lies in their composability. The entire implementation is this:
{ this_parent = parent; this_cancelled = false; } { return this_cancelled || this_cancelled = this_parent ? this_parentcancelled : false; } { this_cancelled = true; }
Usage
Each example builds on the previous in order.
create
; let token = ;
conditional work
let jobs = ; { return { if !tokencancelled ; };} { let token = ; jobs
cancelling work
let scheduledJob = ;scheduledJob;
inheritance
let grandParentToken = ;let parentToken = grandParentToken; { let token = parentToken; jobs