Repository: ocaml-multicore/picos
Pull request #136 (2024-05-12 09:32:54)

Rename `Picos_mpsc_queue` to `Picos_mpscq`
This in preparation for further additions and also finally corrects the benchmark name, which used to refer to "foundation", which was an internal library that has since been removed.


Patch:
diff --git a/bench/bench_mpsc_queue.ml b/bench/bench_mpscq.ml
similarity index 98%
rename from bench/bench_mpsc_queue.ml
rename to bench/bench_mpscq.ml
index b246c3f..9167d5a 100644
--- a/bench/bench_mpsc_queue.ml
+++ b/bench/bench_mpscq.ml
@@ -1,5 +1,5 @@
 open Multicore_bench
-module Queue = Picos_mpsc_queue
+module Queue = Picos_mpscq
 
 let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
   let t = Queue.create () in
diff --git a/bench/dune b/bench/dune
index 4858f4a..53a71e1 100644
--- a/bench/dune
+++ b/bench/dune
@@ -4,7 +4,7 @@
   (run %{test} -brief))
  (libraries
   picos
-  picos.mpsc_queue
+  picos.mpscq
   picos.htbl
   picos.sync
   picos.domain
diff --git a/bench/main.ml b/bench/main.ml
index fd56830..0425b7b 100644
--- a/bench/main.ml
+++ b/bench/main.ml
@@ -12,7 +12,7 @@ let benchmarks =
     ("Picos Yield", Bench_yield.run_suite);
     ("Picos Cancel_after with Picos_select", Bench_cancel_after.run_suite);
     ("Ref with Picos_sync.Mutex", Bench_ref_mutex.run_suite);
-    ("Foundation Mpsc_queue", Bench_mpsc_queue.run_suite);
+    ("Picos_mpscq", Bench_mpscq.run_suite);
     ("Picos_htbl", Bench_htbl.run_suite);
     ("Picos_stdio", Bench_stdio.run_suite);
   ]
diff --git a/lib/index.mld b/lib/index.mld
index 932e689..f6579dd 100644
--- a/lib/index.mld
+++ b/lib/index.mld
@@ -182,7 +182,7 @@ implementation of the other libraries.
   Picos_exn_bt
   Picos_fd
   Picos_htbl
-  Picos_mpsc_queue
+  Picos_mpscq
   Picos_rc
   Picos_thread
 }
diff --git a/lib/picos_fifos/dune b/lib/picos_fifos/dune
index 0d42922..765b2a4 100644
--- a/lib/picos_fifos/dune
+++ b/lib/picos_fifos/dune
@@ -10,4 +10,4 @@
    from
    (picos.select -> select.some.ml)
    (-> select.none.ml))
-  picos.mpsc_queue))
+  picos.mpscq))
diff --git a/lib/picos_fifos/picos_fifos.ml b/lib/picos_fifos/picos_fifos.ml
index 93c3081..54e5636 100644
--- a/lib/picos_fifos/picos_fifos.ml
+++ b/lib/picos_fifos/picos_fifos.ml
@@ -1,5 +1,5 @@
 open Picos
-module Queue = Picos_mpsc_queue
+module Queue = Picos_mpscq
 
 (* As a minor optimization, we avoid allocating closures, which take slightly
    more memory than values of this type. *)
diff --git a/lib/picos_mpsc_queue/dune b/lib/picos_mpsc_queue/dune
deleted file mode 100644
index 6ccf718..0000000
--- a/lib/picos_mpsc_queue/dune
+++ /dev/null
@@ -1,8 +0,0 @@
-(library
- (name picos_mpsc_queue)
- (public_name picos.mpsc_queue)
- (libraries backoff multicore-magic))
-
-(mdx
- (libraries picos.mpsc_queue)
- (files picos_mpsc_queue.mli))
diff --git a/lib/picos_mpscq/dune b/lib/picos_mpscq/dune
new file mode 100644
index 0000000..2be09f6
--- /dev/null
+++ b/lib/picos_mpscq/dune
@@ -0,0 +1,8 @@
+(library
+ (name picos_mpscq)
+ (public_name picos.mpscq)
+ (libraries backoff multicore-magic))
+
+(mdx
+ (libraries picos.mpscq)
+ (files picos_mpscq.mli))
diff --git a/lib/picos_mpsc_queue/picos_mpsc_queue.ml b/lib/picos_mpscq/picos_mpscq.ml
similarity index 100%
rename from lib/picos_mpsc_queue/picos_mpsc_queue.ml
rename to lib/picos_mpscq/picos_mpscq.ml
diff --git a/lib/picos_mpsc_queue/picos_mpsc_queue.mli b/lib/picos_mpscq/picos_mpscq.mli
similarity index 82%
rename from lib/picos_mpsc_queue/picos_mpsc_queue.mli
rename to lib/picos_mpscq/picos_mpscq.mli
index 593461d..ba37cbc 100644
--- a/lib/picos_mpsc_queue/picos_mpsc_queue.mli
+++ b/lib/picos_mpscq/picos_mpscq.mli
@@ -43,22 +43,22 @@ val pop_all : 'a t -> 'a Seq.t
 
     An example top-level session:
     {[
-      # let q : int Picos_mpsc_queue.t =
-          Picos_mpsc_queue.create ()
-      val q : int Picos_mpsc_queue.t = <abstr>
+      # let q : int Picos_mpscq.t =
+          Picos_mpscq.create ()
+      val q : int Picos_mpscq.t = <abstr>
 
-      # Picos_mpsc_queue.push q 42
+      # Picos_mpscq.push q 42
       - : unit = ()
 
-      # Picos_mpsc_queue.push_head q 76
+      # Picos_mpscq.push_head q 76
       - : unit = ()
 
-      # Picos_mpsc_queue.push q 101
+      # Picos_mpscq.push q 101
       - : unit = ()
 
-      # Picos_mpsc_queue.pop_exn q
+      # Picos_mpscq.pop_exn q
       - : int = 76
 
-      # Picos_mpsc_queue.pop_all q |> List.of_seq
+      # Picos_mpscq.pop_all q |> List.of_seq
       - : int list = [42; 101]
     ]} *)


Test patch:
diff --git a/test/dune b/test/dune
index 5e8403e..a7a9395 100644
--- a/test/dune
+++ b/test/dune
@@ -68,12 +68,7 @@
 (test
  (name test_stdio)
  (modules test_stdio)
- (libraries
-  test_scheduler
-  picos.mpsc_queue
-  picos.stdio
-  picos.structured
-  alcotest))
+ (libraries test_scheduler picos.mpscq picos.stdio picos.structured alcotest))
 
 ;;
 
@@ -104,10 +99,10 @@
 ;;
 
 (test
- (name test_mpsc_queue)
- (modules test_mpsc_queue)
+ (name test_mpscq)
+ (modules test_mpscq)
  (libraries
-  picos.mpsc_queue
+  picos.mpscq
   qcheck-core
   qcheck-multicoretests-util
   qcheck-stm.stm
@@ -151,7 +146,7 @@
  (modules test_structured)
  (libraries
   picos
-  picos.mpsc_queue
+  picos.mpscq
   picos.structured
   picos.sync
   test_scheduler
diff --git a/test/test_mpsc_queue.ml b/test/test_mpscq.ml
similarity index 95%
rename from test/test_mpsc_queue.ml
rename to test/test_mpscq.ml
index 768c6d0..c7e8a64 100644
--- a/test/test_mpsc_queue.ml
+++ b/test/test_mpscq.ml
@@ -1,4 +1,4 @@
-module Queue = Picos_mpsc_queue
+module Queue = Picos_mpscq
 
 module Spec = struct
   type cmd = Push of int | Push_head of int | Pop | Pop_all
@@ -87,4 +87,4 @@ let () =
     in
     [ agree_test_par_asym ~count ~name:(name ^ " parallel") ]
   in
-  Stm_run.run ~name:"Picos_mpsc_queue" ~make_domain (module Spec) |> exit
+  Stm_run.run ~name:"Picos_mpscq" ~make_domain (module Spec) |> exit
diff --git a/test/test_stdio.ml b/test/test_stdio.ml
index 135a6d7..5d19bca 100644
--- a/test/test_stdio.ml
+++ b/test/test_stdio.ml
@@ -71,7 +71,7 @@ let test_select () =
   Unix.set_nonblock syn_inn;
   Unix.set_nonblock syn_out;
 
-  let events = Picos_mpsc_queue.create () in
+  let events = Picos_mpscq.create () in
 
   Bundle.join_after @@ fun bundle ->
   Bundle.fork bundle
@@ -81,17 +81,17 @@ let test_select () =
           match Unix.select [ msg_inn1; msg_inn2 ] [] [] 0.1 with
           | inns, _, _ ->
               if List.exists (( == ) msg_inn1) inns then begin
-                Picos_mpsc_queue.push events (Printf.sprintf "Inn1");
+                Picos_mpscq.push events (Printf.sprintf "Inn1");
                 assert (1 = Unix.read msg_inn1 (Bytes.create 1) 0 1);
                 assert (1 = Unix.write_substring syn_out "!" 0 1)
               end;
               if List.exists (( == ) msg_inn2) inns then begin
-                Picos_mpsc_queue.push events (Printf.sprintf "Inn2");
+                Picos_mpscq.push events (Printf.sprintf "Inn2");
                 assert (1 = Unix.read msg_inn2 (Bytes.create 1) 0 1);
                 assert (1 = Unix.write_substring syn_out "!" 0 1)
               end;
               if [] == inns then begin
-                Picos_mpsc_queue.push events (Printf.sprintf "Timeout");
+                Picos_mpscq.push events (Printf.sprintf "Timeout");
                 assert (1 = Unix.write_substring syn_out "!" 0 1)
               end
         done
@@ -108,7 +108,7 @@ let test_select () =
 
   Alcotest.(check' (list string))
     ~msg:"events"
-    ~actual:(Picos_mpsc_queue.pop_all events |> List.of_seq)
+    ~actual:(Picos_mpscq.pop_all events |> List.of_seq)
     ~expected:[ "Inn1"; "Inn2"; "Timeout" ]
 
 let () =
diff --git a/test/test_structured.ml b/test/test_structured.ml
index 2626f60..4733a93 100644
--- a/test/test_structured.ml
+++ b/test/test_structured.ml
@@ -165,9 +165,9 @@ let test_any_and_all_errors () =
   [ Run.all; Run.any ]
   |> List.iter @@ fun run_op ->
      Test_scheduler.run ~max_domains:6 @@ fun () ->
-     let raised = Picos_mpsc_queue.create () in
+     let raised = Picos_mpscq.create () in
      let raiser exn () =
-       Picos_mpsc_queue.push raised exn;
+       Picos_mpscq.push raised exn;
        raise exn
      in
      match
@@ -190,7 +190,7 @@ let test_any_and_all_errors () =
            | Control.Errors exn_bts -> exn_bts
            | exn -> [ Exn_bt.get exn ]
          in
-         Picos_mpsc_queue.pop_all raised
+         Picos_mpscq.pop_all raised
          |> Seq.iter @@ fun exn ->
             assert (
               exn_bts