Fiber.FLSFiber local storage
Fiber local storage is intended for use as a low overhead storage mechanism for fiber extensions. For example, one might associate a priority value with each fiber for a scheduler that uses a priority queue or one might use FLS to store unique id values for fibers.
val create : unit -> 'a tnew_key initial allocates a new key for associating values in storage associated with fibers. The initial value for every fiber is either the given Constant or is Computed with the given function. If the initial value is a constant, no value needs to be stored unless the value is explicitly updated.
⚠️ New keys should not be created dynamically.
get_exn fiber key returns the value associated with the key in the storage associated with the fiber or raises Not_set using raise_notrace.
⚠️ It is only safe to call get_exn from the fiber itself or when the fiber is known not to be running.
get fiber key ~default returns the value associated with the key in the storage associated with the fiber or the default value.
⚠️ It is only safe to call get from the fiber itself or when the fiber is known not to be running.