diff --git a/src/fib/coop_lock.ml b/src/core/coop_lock.ml similarity index 98% rename from src/fib/coop_lock.ml rename to src/core/coop_lock.ml index eb42f792..469d4ae4 100644 --- a/src/fib/coop_lock.ml +++ b/src/core/coop_lock.ml @@ -27,7 +27,7 @@ let rec lock_ (self : 'a t) : 'a = let old = A.get self.st in if old.locked then ( (* suspend and add myself to the [waiters] queue *) - Moonpool.Private.Suspend_.suspend + Suspend_.suspend { handle = (fun ~run:_ ~resume k -> diff --git a/src/fib/coop_lock.mli b/src/core/coop_lock.mli similarity index 71% rename from src/fib/coop_lock.mli rename to src/core/coop_lock.mli index 894878e5..0d5f451c 100644 --- a/src/fib/coop_lock.mli +++ b/src/core/coop_lock.mli @@ -5,8 +5,12 @@ type 'a t val create : 'a -> 'a t (** New lock *) +[@@@ifge 5.0] + val with_lock : 'a t -> ('a -> 'b) -> 'b -(** [with_lock lock f] calls [f] with the lock's content *) +(** [with_lock lock f] calls [f] with the lock's content. *) val with_lock_update : 'a t -> ('a -> 'a * 'b) -> 'b val with_try_lock : 'a t -> ('a option -> 'b) -> 'b + +[@@@endif] diff --git a/src/core/moonpool.ml b/src/core/moonpool.ml index cafac26c..4c02ad44 100644 --- a/src/core/moonpool.ml +++ b/src/core/moonpool.ml @@ -23,6 +23,7 @@ module Blocking_queue = Bb_queue module Background_thread = Background_thread module Bounded_queue = Bounded_queue module Chan = Chan +module Coop_lock = Coop_lock module Exn_bt = Exn_bt module Fifo_pool = Fifo_pool module Fut = Fut diff --git a/src/core/moonpool.mli b/src/core/moonpool.mli index c0d495c9..fe20b3d1 100644 --- a/src/core/moonpool.mli +++ b/src/core/moonpool.mli @@ -75,6 +75,7 @@ val await : 'a Fut.t -> 'a [@@@endif] module Lock = Lock +module Coop_lock = Coop_lock module Fut = Fut module Chan = Chan module Task_local_storage = Task_local_storage diff --git a/src/fib/moonpool_fib.ml b/src/fib/moonpool_fib.ml index 9359303f..ec89c075 100644 --- a/src/fib/moonpool_fib.ml +++ b/src/fib/moonpool_fib.ml @@ -8,6 +8,5 @@ module Fiber = Fiber module Fls = Fls module Handle = Handle module Main = Main -module Coop_lock = Coop_lock include Fiber include Main