diff --git a/src/client/notifier_sync.ml b/src/client/notifier_sync.ml index 4ce44bb8..d418cb59 100644 --- a/src/client/notifier_sync.ml +++ b/src/client/notifier_sync.ml @@ -1,8 +1,21 @@ -include Util_thread.MCond module IO = Generic_io.Direct_style +type t = { + mutex: Mutex.t; + cond: Condition.t; +} + +let create () : t = { mutex = Mutex.create (); cond = Condition.create () } + +let trigger self = Condition.signal self.cond + let delete = ignore -let trigger = signal +let[@inline] protect self f = Util_mutex.protect self.mutex f -let register_bounded_queue = wakeup_from_bq +(** NOTE: the mutex must be acquired *) +let wait self = Condition.wait self.cond self.mutex + +(** Ensure we get signalled when the queue goes from empty to non-empty *) +let register_bounded_queue (self : t) (bq : _ Bounded_queue.t) : unit = + Bounded_queue.on_non_empty bq (fun () -> trigger self) diff --git a/src/client/util_thread.ml b/src/client/util_thread.ml index 37764ac3..75479688 100644 --- a/src/client/util_thread.ml +++ b/src/client/util_thread.ml @@ -42,23 +42,3 @@ let setup_ticker_thread ~stop ~sleep_ms (exp : OTEL.Exporter.t) () = (Printexc.to_string exn) in start_bg_thread tick_loop - -module MCond = struct - type t = { - mutex: Mutex.t; - cond: Condition.t; - } - - let create () : t = { mutex = Mutex.create (); cond = Condition.create () } - - let signal self = Condition.signal self.cond - - let[@inline] protect self f = Util_mutex.protect self.mutex f - - (** NOTE: the mutex must be acquired *) - let wait self = Condition.wait self.cond self.mutex - - (** Ensure we get signalled when the queue goes from empty to non-empty *) - let wakeup_from_bq (self : t) (bq : _ Bounded_queue.t) : unit = - Bounded_queue.on_non_empty bq (fun () -> signal self) -end