| 1 | (* From memprof-limits *) |
| 2 | val is_interrupted : unit -> bool |
| 3 | |
| 4 | module Masking : sig |
| 5 | |
| 6 | val with_resource : |
| 7 | acquire:('a -> 'b) -> 'a -> scope:('b -> 'c) -> release:('b -> unit) -> 'c |
| 8 | |
| 9 | end |
| 10 | |
| 11 | module Thread_map : sig |
| 12 | |
| 13 | (** An async-safe, scoped thread-local store *) |
| 14 | |
| 15 | type 'a t |
| 16 | |
| 17 | val create : unit -> 'a t |
| 18 | (** Create an empty map *) |
| 19 | |
| 20 | val with_value : 'a t -> value:'a -> scope:(unit -> 'b) -> 'b |
| 21 | (** Associate [~value] to the current thread for the duration of a scope. |
| 22 | It can be nested: the previous association is restored on exit. *) |
| 23 | |
| 24 | val get : 'a t -> 'a option |
| 25 | (** Get the value currently associated with the current thread. *) |
| 26 | |
| 27 | end |
| 28 | |
| 29 | module Resource_bind : sig |
| 30 | (** Open {!Memprof_limits.Resource_bind} to enable the [let&] binder |
| 31 | for resources. *) |
| 32 | |
| 33 | val ( let& ) : (scope:('a -> 'b) -> 'b) -> ('a -> 'b) -> 'b |
| 34 | (** RAII-style notation for resources cleaned-up at the end of |
| 35 | scope. Example: |
| 36 | {[open Memprof_limits.Resource_bind |
| 37 | |
| 38 | let with_my_resource x = |
| 39 | Memprof_limits.Masking.with_resource ~acquire x ~release |
| 40 | |
| 41 | let f x = |
| 42 | let& resource = with_my_resource x in |
| 43 | …]} *) |
| 44 | end |
| 45 | |
| 46 | module Mutex_aux : sig |
| 47 | |
| 48 | val with_lock : Mutex.t -> scope:(unit -> 'a) -> 'a |
| 49 | |
| 50 | end |