package moonpool
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=3efd095c82a37bba8c7ab6a2532aee3c445ebe1ecaed84ef3ffb560bc65e7633
sha512=e4bcab82e6638299c2d0beb1dbf204f7b43379a5387418c6edff85b9bf90c13ad1bdd8eb44b69cd421268d1bc45bcf918bcf77e1c924348211ac27d6643aac78
doc/moonpool.fib/Moonpool_fib/Fls/index.html
Module Moonpool_fib.FlsSource
Fiber-local storage.
This storage is associated to the current fiber, just like thread-local storage is associated with the current thread.
See Moonpool.Task_local_storage for more general information, as this is based on it.
NOTE: it's important to note that, while each fiber has its own storage, spawning a sub-fiber f2 from a fiber f1 will only do a shallow copy of the storage. Values inside f1's storage will be physically shared with f2. It is thus recommended to store only persistent values in the local storage.
include module type of struct include Moonpool.Task_local_storage end
Underlying storage for a task. This is mutable and not thread-safe.
A key used to access a particular (typed) storage slot on every task.
new_key ~init () makes a new key. Keys are expensive and should never be allocated dynamically or in a loop. The correct pattern is, at toplevel:
let k_foo : foo Task_ocal_storage.key =
Task_local_storage.new_key ~init:(fun () -> make_foo ()) ()
(* … *)
(* use it: *)
let … = Task_local_storage.get k_fooget k gets the value for the current task for key k. Must be run from inside a task running on a runner.
get_opt k gets the current task's value for key k, or None if not run from inside the task.
set k v sets the storage for k to v. Must be run from inside a task running on a runner.
with_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.
Access the current storage, or None if not run from within a task.
Direct access to values from a storage handle