1
2
3
4
5
6
7
8
9
10
11
let lock_ : (unit -> unit) ref = ref ignore
let unlock_ : (unit -> unit) ref = ref ignore
let set_mutex ~lock ~unlock : unit =
lock_ := lock;
unlock_ := unlock
let[@inline] with_lock f =
!lock_ ();
Fun.protect ~finally:!unlock_ f