Skip to content

Commit

Permalink
Move auxiliary libs to separate package
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Sep 2, 2024
1 parent f036c27 commit 58086c5
Show file tree
Hide file tree
Showing 49 changed files with 158 additions and 114 deletions.
8 changes: 4 additions & 4 deletions bench/bench_binaries.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ let paths =
lib "picos" ~subs:[ "bootstrap"; "ocaml5"; "ocaml4" ];
lib "picos.domain";
lib "picos.thread";
lib "picos_aux.htbl";
lib "picos_aux.mpmcq";
lib "picos_aux.mpscq";
lib "picos_aux.rc";
lib "picos_lwt";
lib "picos_lwt.unix";
lib "picos_mux.fifo";
Expand All @@ -23,10 +27,6 @@ let paths =
lib "picos_mux.thread";
lib "picos_std.event";
lib "picos_std.finally";
lib "picos_std.htbl";
lib "picos_std.mpmcq";
lib "picos_std.mpscq";
lib "picos_std.rc";
lib "picos_std.structured";
lib "picos_std.sync";
lib "picos_stdio";
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_htbl.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Multicore_bench
module Htbl = Picos_std_htbl
module Htbl = Picos_aux_htbl

module Key = struct
type t = int
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_mpmcq.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Multicore_bench
module Mpmcq = Picos_std_mpmcq
module Mpmcq = Picos_aux_mpmcq

let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
let t = Mpmcq.create ~padded:true () in
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_mpscq.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Multicore_bench
module Mpscq = Picos_std_mpscq
module Mpscq = Picos_aux_mpscq

let run_one_domain ~budgetf ?(n_msgs = 50 * Util.iter_factor) () =
let t = Mpscq.create ~padded:true () in
Expand Down
6 changes: 3 additions & 3 deletions bench/dune
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
picos
picos.domain
picos.thread
picos_aux.htbl
picos_aux.mpmcq
picos_aux.mpscq
picos_std.finally
picos_std.htbl
picos_std.mpmcq
picos_std.mpscq
picos_std.structured
picos_std.sync
picos_stdio
Expand Down
16 changes: 16 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@

(using mdx 0.4)

(package
(name picos_aux)
(synopsis "Auxiliary libraries for Picos")
(depends
(ocaml
(>= 4.14.0))
;;
(backoff
(>= 0.1.0))
(multicore-magic
(>= 2.3.0))
;;
))

(package
(name picos)
(synopsis "Pico scheduler interface")
Expand Down Expand Up @@ -125,6 +139,8 @@
(depends
(picos
(= :version))
(picos_aux
(= :version))
(picos_std
(= :version))
(picos_stdio
Expand Down
8 changes: 4 additions & 4 deletions lib/picos_std.htbl/dune → lib/picos_aux.htbl/dune
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(library
(name picos_std_htbl)
(public_name picos_std.htbl)
(name picos_aux_htbl)
(public_name picos_aux.htbl)
(libraries backoff multicore-magic))

(mdx
(package picos_meta)
(enabled_if
(>= %{ocaml_version} 5.1.0))
(libraries picos_std.htbl)
(files picos_std_htbl.mli))
(libraries picos_aux.htbl)
(files picos_aux_htbl.mli))
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ val remove_all : ('k, 'v) t -> ('k * 'v) Seq.t
An example top-level session:
{[
# let t : (int, string) Picos_std_htbl.t =
Picos_std_htbl.create
# let t : (int, string) Picos_aux_htbl.t =
Picos_aux_htbl.create
~hashed_type:(module Int) ()
val t : (int, string) Picos_std_htbl.t = <abstr>
val t : (int, string) Picos_aux_htbl.t = <abstr>
# Picos_std_htbl.try_add t 42 "The answer"
# Picos_aux_htbl.try_add t 42 "The answer"
- : bool = true
# Picos_std_htbl.try_add t 101 "Basics"
# Picos_aux_htbl.try_add t 101 "Basics"
- : bool = true
# Picos_std_htbl.find_exn t 42
# Picos_aux_htbl.find_exn t 42
- : string = "The answer"
# Picos_std_htbl.try_add t 101 "The basics"
# Picos_aux_htbl.try_add t 101 "The basics"
- : bool = false
# Picos_std_htbl.remove_all t |> List.of_seq
# Picos_aux_htbl.remove_all t |> List.of_seq
- : (int * string) list = [(101, "Basics"); (42, "The answer")]
]} *)
9 changes: 9 additions & 0 deletions lib/picos_aux.mpmcq/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library
(name picos_aux_mpmcq)
(public_name picos_aux.mpmcq)
(libraries backoff multicore-magic))

(mdx
(package picos_meta)
(libraries picos_aux.mpmcq)
(files picos_aux_mpmcq.mli))
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,31 @@ val is_empty : 'a t -> bool
An example top-level session:
{[
# let q : int Picos_std_mpmcq.t =
Picos_std_mpmcq.create ()
val q : int Picos_std_mpmcq.t = <abstr>
# let q : int Picos_aux_mpmcq.t =
Picos_aux_mpmcq.create ()
val q : int Picos_aux_mpmcq.t = <abstr>
# Picos_std_mpmcq.push q 42
# Picos_aux_mpmcq.push q 42
- : unit = ()
# Picos_std_mpmcq.push_head q 76
# Picos_aux_mpmcq.push_head q 76
- : unit = ()
# Picos_std_mpmcq.length q
# Picos_aux_mpmcq.length q
- : int = 2
# Picos_std_mpmcq.push q 101
# Picos_aux_mpmcq.push q 101
- : unit = ()
# Picos_std_mpmcq.pop_exn q
# Picos_aux_mpmcq.pop_exn q
- : int = 76
# Picos_std_mpmcq.pop_exn q
# Picos_aux_mpmcq.pop_exn q
- : int = 42
# Picos_std_mpmcq.pop_exn q
# Picos_aux_mpmcq.pop_exn q
- : int = 101
# Picos_std_mpmcq.pop_exn q
Exception: Picos_std_mpmcq.Empty.
# Picos_aux_mpmcq.pop_exn q
Exception: Picos_aux_mpmcq.Empty.
]} *)
9 changes: 9 additions & 0 deletions lib/picos_aux.mpscq/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library
(name picos_aux_mpscq)
(public_name picos_aux.mpscq)
(libraries backoff multicore-magic))

(mdx
(package picos_meta)
(libraries picos_aux.mpscq)
(files picos_aux_mpscq.mli))
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ val pop_all : 'a t -> 'a Seq.t
An example top-level session:
{[
# let q : int Picos_std_mpscq.t =
Picos_std_mpscq.create ()
val q : int Picos_std_mpscq.t = <abstr>
# let q : int Picos_aux_mpscq.t =
Picos_aux_mpscq.create ()
val q : int Picos_aux_mpscq.t = <abstr>
# Picos_std_mpscq.push q 42
# Picos_aux_mpscq.push q 42
- : unit = ()
# Picos_std_mpscq.push_head q 76
# Picos_aux_mpscq.push_head q 76
- : unit = ()
# Picos_std_mpscq.push q 101
# Picos_aux_mpscq.push q 101
- : unit = ()
# Picos_std_mpscq.pop_exn q
# Picos_aux_mpscq.pop_exn q
- : int = 76
# Picos_std_mpscq.pop_all q |> List.of_seq
# Picos_aux_mpscq.pop_all q |> List.of_seq
- : int list = [42; 101]
]} *)
4 changes: 4 additions & 0 deletions lib/picos_aux.rc/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name picos_aux_rc)
(public_name picos_aux.rc)
(libraries backoff picos_aux.htbl))
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let count_1 = 1 lsl count_shift
let dispose_bit = 0b01
let closed_bit = 0b10

module Htbl = Picos_std_htbl
module Htbl = Picos_aux_htbl

module Make (Resource : Resource) () : S with module Resource = Resource =
struct
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions lib/picos_aux/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(documentation
(package picos_aux)
(mld_files index))
13 changes: 13 additions & 0 deletions lib/picos_aux/index.mld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{0 Auxiliary libraries for Picos}

This package contains auxiliary libraries used in the implementation of other
Picos libraries.

{!modules:
Picos_aux_htbl
Picos_aux_mpmcq
Picos_aux_mpscq
Picos_aux_rc
}

{^ Some of these libraries might be moved to other packages in the future.}
2 changes: 1 addition & 1 deletion lib/picos_lwt.unix/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
(re_export lwt.unix)
(re_export picos_lwt)
picos.thread
picos_std.mpscq
picos_aux.mpscq
unix))
2 changes: 1 addition & 1 deletion lib/picos_lwt.unix/picos_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Picos
let[@inline never] not_main_thread () =
invalid_arg "not called from the main thread"

module Mpscq = Picos_std_mpscq
module Mpscq = Picos_aux_mpscq

let ready = Mpscq.create ~padded:true ()

Expand Down
2 changes: 1 addition & 1 deletion lib/picos_mux.fifo/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
(picos_stdio.select -> select.some.ml)
(-> select.none.ml))
multicore-magic
picos_std.mpscq))
picos_aux.mpscq))
2 changes: 1 addition & 1 deletion lib/picos_mux.fifo/picos_mux_fifo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ready =
* ((exn * Printexc.raw_backtrace) option, unit) Effect.Deep.continuation
| Return of Fiber.Maybe.t * (unit, unit) Effect.Deep.continuation

module Mpscq = Picos_std_mpscq
module Mpscq = Picos_aux_mpscq

type t = {
ready : ready Mpscq.t;
Expand Down
2 changes: 1 addition & 1 deletion lib/picos_mux.multififo/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
(-> select.none.ml))
multicore-magic
picos.thread
picos_std.mpmcq))
picos_aux.mpmcq))
2 changes: 1 addition & 1 deletion lib/picos_mux.multififo/picos_mux_multififo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let[@inline never] quota_non_positive () = invalid_arg "quota must be positive"
let[@inline never] already_running () = invalid_arg "already running"
let[@inline never] not_worker () = invalid_arg "not a worker thread"

module Mpmcq = Picos_std_mpmcq
module Mpmcq = Picos_aux_mpmcq

type ready =
| Spawn of Fiber.t * (Fiber.t -> unit)
Expand Down
2 changes: 1 addition & 1 deletion lib/picos_mux.random/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
(-> select.none.ml))
multicore-magic
picos.thread
picos_std.htbl))
picos_aux.htbl))
2 changes: 1 addition & 1 deletion lib/picos_mux.random/picos_mux_random.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Picos
module Htbl = Picos_std_htbl
module Htbl = Picos_aux_htbl

module Collection = struct
type 'a t = (int, 'a) Htbl.t
Expand Down
9 changes: 0 additions & 9 deletions lib/picos_std.mpmcq/dune

This file was deleted.

9 changes: 0 additions & 9 deletions lib/picos_std.mpscq/dune

This file was deleted.

4 changes: 0 additions & 4 deletions lib/picos_std.rc/dune

This file was deleted.

23 changes: 2 additions & 21 deletions lib/picos_std/index.mld
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{0 Sample libraries for Picos}

This package contains scheduler agnostic libraries for {!Picos} as well as some
auxiliary libraries used in their implementation. Many of the modules are
intentionally designed to mimic modules from the OCaml Stdlib.

{1 Scheduler agnostic libraries}

These are examples of libraries implemented in Picos.
This package contains sample scheduler agnostic libraries for {!Picos}. Many of
the modules are intentionally designed to mimic modules from the OCaml Stdlib.

{!modules:
Picos_std_finally
Expand All @@ -20,17 +15,3 @@ These are examples of libraries implemented in Picos.
will be many more libraries implemented in Picos like these providing
different approaches, patterns, and idioms for structuring concurrent
programs.}

{1 Auxiliary libraries}

These have no dependency to the core {!Picos} interface and are used in the
implementation of the other libraries.

{!modules:
Picos_std_htbl
Picos_std_mpmcq
Picos_std_mpscq
Picos_std_rc
}

{^ Some of these libraries might be moved to other packages in the future.}
2 changes: 1 addition & 1 deletion lib/picos_stdio.fd/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
(public_name picos_stdio.fd)
(libraries
(re_export unix)
picos_std.rc))
picos_aux.rc))
2 changes: 1 addition & 1 deletion lib/picos_stdio.fd/picos_stdio_fd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module File_descr = struct
let dispose = Unix.close
end

include Picos_std_rc.Make (File_descr) ()
include Picos_aux_rc.Make (File_descr) ()

let () =
Stdlib.at_exit @@ fun () ->
Expand Down
2 changes: 1 addition & 1 deletion lib/picos_stdio.fd/picos_stdio_fd.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ val report_leaks : bool ref
(** If [!report_leaks = true] then undisposed file descriptors will be reported
{{!Stdlib.at_exit} at exit}. *)

include Picos_std_rc.S with type Resource.t = Unix.file_descr
include Picos_aux_rc.S with type Resource.t = Unix.file_descr
Loading

0 comments on commit 58086c5

Please sign in to comment.