Browse Source

use Mpsc for DCE (#12157)

Simon Krajewski 4 months ago
parent
commit
2e6c8ae124
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/core/ds/nowOrLater.ml

+ 6 - 6
src/core/ds/nowOrLater.ml

@@ -1,13 +1,13 @@
+module Mpsc = Saturn.Single_consumer_queue
+
 type t = {
 type t = {
 	now : Mutex.t;
 	now : Mutex.t;
-	later: (unit -> unit) Queue.t;
-	later_mutex : Mutex.t;
+	later: (unit -> unit) Mpsc.t;
 }
 }
 
 
 let create () = {
 let create () = {
 	now = Mutex.create ();
 	now = Mutex.create ();
-	later = Queue.create ();
-	later_mutex = Mutex.create ();
+	later = Mpsc.create ();
 }
 }
 
 
 let try_now nol f =
 let try_now nol f =
@@ -15,11 +15,11 @@ let try_now nol f =
 		f();
 		f();
 		Mutex.unlock nol.now
 		Mutex.unlock nol.now
 	end else begin
 	end else begin
-		Mutex.protect nol.later_mutex (fun () -> Queue.push f nol.later)
+		Mpsc.push nol.later f
 	end
 	end
 
 
 let handle_later nol =
 let handle_later nol =
-	let rec loop () = match Queue.take_opt nol.later with
+	let rec loop () = match Mpsc.pop_opt nol.later with
 		| Some f ->
 		| Some f ->
 			f ();
 			f ();
 			loop ()
 			loop ()