mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
improve lock
This commit is contained in:
parent
a40ea8b41b
commit
794b263d36
1 changed files with 4 additions and 4 deletions
|
|
@ -42,13 +42,13 @@ module Lock = struct
|
||||||
|
|
||||||
let create content : _ t = { mutex = Mutex.create (); content }
|
let create content : _ t = { mutex = Mutex.create (); content }
|
||||||
|
|
||||||
let with_ (self : _ t) f =
|
let[@inline never] with_ (self : _ t) f =
|
||||||
Mutex.lock self.mutex;
|
Mutex.lock self.mutex;
|
||||||
try
|
match f self.content with
|
||||||
let x = f self.content in
|
| x ->
|
||||||
Mutex.unlock self.mutex;
|
Mutex.unlock self.mutex;
|
||||||
x
|
x
|
||||||
with e ->
|
| exception e ->
|
||||||
Mutex.unlock self.mutex;
|
Mutex.unlock self.mutex;
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue