expose Task_local_storage.get_current

This commit is contained in:
Simon Cruanes 2024-03-01 19:02:46 -05:00
parent 45b8aa9999
commit 8c10c2b329
2 changed files with 6 additions and 0 deletions

View file

@ -77,3 +77,5 @@ let with_value key x f =
let old = get key in
set key x;
Fun.protect ~finally:(fun () -> set key old) f
let get_current = get_current_storage

View file

@ -52,6 +52,10 @@ val with_value : 'a key -> 'a -> (unit -> 'b) -> 'b
to [f()]. When [f()] returns (or fails), [k] is restored
to its old value. *)
val get_current : unit -> t option
(** Access the current storage, or [None] if not run from
within a task. *)
(** Direct access to values from a storage handle *)
module Direct : sig
val get : t -> 'a key -> 'a