Alis for update.
Returns the current value of this Local
.
Execute a block with a specific local value, restoring the current state upon completion.
Execute a block with a specific local value, restoring the current state upon completion.
The implementation uses the CanBindLocals
type class because in case of asynchronous data types that
should be waited on, like Future
or CompletableFuture
,
then the locals context also needs to be cleared on the
future's completion, for correctness.
Execute a block with the Local
cleared, restoring the current
state upon completion.
Execute a block with the Local
cleared, restoring the current
state upon completion.
The implementation uses the CanBindLocals
type class because in case of asynchronous data types that
should be waited on, like Future
or CompletableFuture
,
then the locals context also needs to be cleared on the
future's completion, for correctness.
Clear the Local's value.
Clear the Local's value. Other Locals are not modified.
General usage should be in Local.isolate to avoid leaks.
Alias for apply.
Updates the value of this Local
.
Returns the current value of this Local
, or None
in
case this local should fallback to the default.
Returns the current value of this Local
, or None
in
case this local should fallback to the default.
Use apply in case automatic fallback is needed.
Updates the current value of this Local
.
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.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.