Moonpool.Task_local_storageTask-local storage.
This storage is associated to the current task, just like thread-local storage is associated with the current thread. The storage is carried along in case the current task is suspended.
type 'a t = 'a Picos.Fiber.FLS.tval create : unit -> 'a tcreate () makes a new key. Keys are expensive and should never be allocated dynamically or in a loop.
val get_exn : 'a t -> 'aget k gets the value for the current task for key k. Must be run from inside a task running on a runner.
val get_opt : 'a t -> 'a optionget_opt k gets the current task's value for key k, or None if not run from inside the task.
val get : 'a t -> default:'a -> 'aval set : 'a t -> 'a -> unitset k v sets the storage for k to v. Must be run from inside a task running on a runner.
val with_value : 'a t -> 'a -> (unit -> 'b) -> 'bwith_value k v f sets k to v for the duration of the call to f(). When f() returns (or fails), k is restored to its old value.
Hmap.tThis requires hmap to be installed.
val k_local_hmap : Hmap.t Picos.Fiber.FLS.tA local hmap, inherited in children fibers
val get_local_hmap : unit -> Hmap.tAccess the local hmap, or an empty one if not set
val set_local_hmap : Hmap.t -> unitval get_in_local_hmap_exn : 'a Hmap.key -> 'aval get_in_local_hmap_opt : 'a Hmap.key -> 'a optionval remove_in_local_hmap : 'a Hmap.key -> unitRemove given key from the local hmap
val set_in_local_hmap : 'a Hmap.key -> 'a -> unitval with_in_local_hmap : 'a Hmap.key -> 'a -> (unit -> 'b) -> 'bwith_in_local_hmap k v f calls f() in a context where k is bound to v in the local hmap. Then it restores the previous binding for k.