Get the Local's optional value.
Clear the Local's value.
Execute a block with a specific Local value, restoring the current state upon completion.
Execute a block with the Local cleared, restoring the current state upon completion.
Update the Local with a given optional value.
Update the Local with a given optional value.
General usage should be via let to avoid leaks.
Update the Local with a given value.
Update the Local with a given value.
General usage should be via let to avoid leaks.
A Local is a ThreadLocal whose scope is flexible. The state of all Locals may be saved or restored onto the current thread by the user. This is useful for threading Locals through execution contexts.
Promises pass locals through control dependencies, not through data dependencies. This means that Locals have exactly the same semantics as ThreadLocals, if you think of
continue
(the asynchronous sequence operator) as semicolon (the synchronous sequence operator).Because it's not meaningful to inherit control from two places, Locals don't have to worry about having to merge two Contexts.
Note: the implementation is optimized for situations in which save and restore optimizations are dominant.