diff --git a/src/core/task_local_storage.ml b/src/core/task_local_storage.ml index 1491b270..b62f4908 100644 --- a/src/core/task_local_storage.ml +++ b/src/core/task_local_storage.ml @@ -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 diff --git a/src/core/task_local_storage.mli b/src/core/task_local_storage.mli index 502661bb..0cb4cc09 100644 --- a/src/core/task_local_storage.mli +++ b/src/core/task_local_storage.mli @@ -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