Skip to content

Commit

Permalink
Rename picos_stdio to picos_io
Browse files Browse the repository at this point in the history
This avoids a linting warning on OPAM CI.
  • Loading branch information
polytypic committed Sep 3, 2024
1 parent 4d53211 commit 1f18591
Show file tree
Hide file tree
Showing 59 changed files with 166 additions and 178 deletions.
12 changes: 6 additions & 6 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
- lib: `picos_std.finally`
- lib: `picos_std.structured`
- lib: `picos_std.sync`
- pkg: `picos_stdio`
- lib: `picos_stdio`
- lib: `picos_stdio.fd`
- lib: `picos_stdio.select`
- pkg: `picos_stdio_cohttp`
- lib: `picos_stdio_cohttp`
- pkg: `picos_io`
- lib: `picos_io`
- lib: `picos_io.fd`
- lib: `picos_io.select`
- pkg: `picos_io_cohttp`
- lib: `picos_io_cohttp`

## 0.4.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ _Implemented in Picos_. These libraries include
[a library for structured concurrency](https://ocaml-multicore.github.io/picos/doc/picos_std/Picos_std_structured/index.html),
[a library of synchronization primitives](https://ocaml-multicore.github.io/picos/doc/picos_std/Picos_std_sync/index.html),
and
[an asynchronous I/O library](https://ocaml-multicore.github.io/picos/doc/picos_stdio/Picos_stdio/index.html).
[an asynchronous I/O library](https://ocaml-multicore.github.io/picos/doc/picos_io/Picos_io/index.html).
The synchronization library and the I/O library intentionally mimic libraries
that come with the OCaml distribution. All of the libraries work with all of the
schedulers and all of these _elements_ are interoperable and entirely opt-in.
Expand Down Expand Up @@ -662,7 +662,7 @@ let run_server server_fd =
```

The
[`Unix`](https://ocaml-multicore.github.io/picos/doc/picos_stdio/Picos_stdio/Unix/index.html)
[`Unix`](https://ocaml-multicore.github.io/picos/doc/picos_io/Picos_io/Unix/index.html)
module is provided by the I/O library. The operations on file descriptors on
that module, such as `accept`, `read`, and `write`, use the Picos interface to
suspend fibers allowing other fibers to run while waiting for I/O. The
Expand Down
8 changes: 4 additions & 4 deletions bench/bench_binaries.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ let paths =
lib "picos_std.finally";
lib "picos_std.structured";
lib "picos_std.sync";
lib "picos_stdio";
lib "picos_stdio.fd";
lib "picos_stdio.select";
lib "picos_stdio_cohttp";
lib "picos_io";
lib "picos_io.fd";
lib "picos_io.select";
lib "picos_io_cohttp";
]

let run_suite ~budgetf:_ =
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_stdio.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Multicore_bench
open Picos_stdio
open Picos_io

let run_one ~budgetf ~block_or_nonblock ~n_domains () =
let block_size = 4096 in
Expand Down
4 changes: 2 additions & 2 deletions bench/dune
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
picos_aux.htbl
picos_aux.mpmcq
picos_aux.mpscq
picos_io
picos_io.select
picos_std.finally
picos_std.structured
picos_std.sync
picos_stdio
picos_stdio.select
(select
scheduler.ml
from
Expand Down
2 changes: 1 addition & 1 deletion bench/main.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let () = Picos_stdio_select.configure ()
let () = Picos_io_select.configure ()

let benchmarks =
[
Expand Down
14 changes: 7 additions & 7 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
))

(package
(name picos_stdio)
(name picos_io)
(synopsis "Asynchronous IO system for Picos")
(depends
(picos_aux
Expand All @@ -83,10 +83,10 @@
))

(package
(name picos_stdio_cohttp)
(synopsis "Cohttp running on Picos stdio")
(name picos_io_cohttp)
(synopsis "Cohttp running on Picos IO")
(depends
(picos_stdio
(picos_io
(= :version))
;;
(cohttp
Expand Down Expand Up @@ -114,7 +114,7 @@
;;
)
(depopts
(picos_stdio
(picos_io
(= :version))
;;
))
Expand Down Expand Up @@ -145,9 +145,9 @@
(= :version))
(picos_std
(= :version))
(picos_stdio
(picos_io
(= :version))
(picos_stdio_cohttp
(picos_io_cohttp
(= :version))
(picos_mux
(= :version))
Expand Down
4 changes: 2 additions & 2 deletions lib/picos_stdio.fd/dune → lib/picos_io.fd/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(library
(name picos_stdio_fd)
(public_name picos_stdio.fd)
(name picos_io_fd)
(public_name picos_io.fd)
(libraries
(re_export unix)
picos_aux.rc))
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions lib/picos_stdio.select/dune → lib/picos_io.select/dune
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(library
(name picos_stdio_select)
(public_name picos_stdio.select)
(name picos_io_select)
(public_name picos_io.select)
(optional)
(libraries
(re_export picos)
(re_export picos_io.fd)
(re_export picos_std.event)
(re_export picos_stdio.fd)
(re_export unix)
backoff
mtime
Expand All @@ -14,7 +14,7 @@
picos.domain
picos.thread
picos_aux.htbl
picos_stdio_thread_atomic
picos_io_thread_atomic
psq
threads.posix))

Expand All @@ -24,11 +24,11 @@
(>= %{ocaml_version} 5.1.0))
(libraries
picos
picos_io
picos_io.select
picos_mux.random
picos_std.event
picos_std.finally
picos_std.structured
picos_stdio
picos_stdio.select
unix)
(files picos_stdio_select.mli))
(files picos_io_select.mli))
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module Q =

type return_on =
| Return_on : {
file_descr : Picos_stdio_fd.t;
file_descr : Picos_io_fd.t;
value : 'a;
computation : 'a Computation.t;
mutable alive : bool;
Expand Down Expand Up @@ -162,18 +162,18 @@ type fos = { n : int; unique_fds : Unix.file_descr list; ops : return_on list }

let fos_empty = { n = 1; unique_fds = []; ops = [] }

module Ht = Hashtbl.Make (Picos_stdio_fd.Resource)
module Ht = Hashtbl.Make (Picos_io_fd.Resource)

let rec process_fds ht unique_fds ops = function
| [] ->
if unique_fds == [] && ops == [] then fos_empty
else { n = Ht.length ht; unique_fds; ops }
| (Return_on r as op) :: ops_todo ->
if Computation.is_running r.computation then begin
let file_descr = Picos_stdio_fd.unsafe_get r.file_descr in
let file_descr = Picos_io_fd.unsafe_get r.file_descr in
match Ht.find ht file_descr with
| `Return ->
Picos_stdio_fd.decr r.file_descr;
Picos_io_fd.decr r.file_descr;
r.alive <- false;
Computation.return r.computation r.value;
process_fds ht unique_fds ops ops_todo
Expand All @@ -183,7 +183,7 @@ let rec process_fds ht unique_fds ops = function
process_fds ht (file_descr :: unique_fds) (op :: ops) ops_todo
end
else begin
Picos_stdio_fd.decr r.file_descr;
Picos_io_fd.decr r.file_descr;
process_fds ht unique_fds ops ops_todo
end

Expand All @@ -210,7 +210,7 @@ let rec process_timeouts s =
Mtime.Span.to_float_ns (Mtime.Span.abs_diff e.time elapsed)
*. (1. /. 1_000_000_000.)

module Thread_atomic = Picos_stdio_thread_atomic
module Thread_atomic = Picos_io_thread_atomic

let rec select_thread s timeout rd wr ex =
if s.state == `Alive then begin
Expand Down Expand Up @@ -424,10 +424,10 @@ let[@alert "-handler"] rec insert_fd s fds (Return_on r as op) =
in
wakeup s `Alive
else insert_fd s fds op
else Picos_stdio_fd.decr r.file_descr
else Picos_io_fd.decr r.file_descr

let return_on computation file_descr op value =
Picos_stdio_fd.incr file_descr;
Picos_io_fd.incr file_descr;
let s = get () in
insert_fd s
(match op with `R -> s.new_rd | `W -> s.new_wr | `E -> s.new_ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ val timeout : seconds:float -> unit Event.t
(** {2 IO} *)

val return_on :
'a Computation.t -> Picos_stdio_fd.t -> [ `R | `W | `E ] -> 'a -> unit
'a Computation.t -> Picos_io_fd.t -> [ `R | `W | `E ] -> 'a -> unit
(** [return_on computation fd op value] arranges for [computation] to be
{{!Picos.Computation.return} returned} with given [value] when [fd] becomes
available for [op]. Completion of the [computation] before the [fd] becomes
Expand All @@ -45,10 +45,10 @@ val return_on :
ℹ️ Using {!Unix.set_nonblock} and [return_on] you can implement direct-style
transparently asynchronous IO on top of the {!Unix} module. *)

val await_on : Picos_stdio_fd.t -> [ `R | `W | `E ] -> Picos_stdio_fd.t
val await_on : Picos_io_fd.t -> [ `R | `W | `E ] -> Picos_io_fd.t
(** [await_on fd op] awaits until [fd] becomes available for [op]. *)

val on : Picos_stdio_fd.t -> [ `R | `W | `E ] -> unit Event.t
val on : Picos_io_fd.t -> [ `R | `W | `E ] -> unit Event.t
(** [on fd op] returns an {{!Picos_std_event.Event} event} that can be committed
to when [fd] becomes available for [op]. *)

Expand Down Expand Up @@ -149,10 +149,10 @@ val handle_signal : int -> unit
{[
open Picos
open Picos_io
open Picos_std_event
open Picos_std_finally
open Picos_std_structured
open Picos_stdio
]}
{2 One of many}
Expand Down Expand Up @@ -201,19 +201,19 @@ val handle_signal : int -> unit
Flock.fork begin fun () ->
while true do
Event.select [
Picos_stdio_select.on msg_inn1 `R
Picos_io_select.on msg_inn1 `R
|> Event.map begin fun () ->
print_endline "Inn1";
read1 msg_inn1;
write1 syn_out
end;
Picos_stdio_select.on msg_inn2 `R
Picos_io_select.on msg_inn2 `R
|> Event.map begin fun () ->
print_endline "Inn2";
read1 msg_inn2;
write1 syn_out;
end;
Picos_stdio_select.timeout
Picos_io_select.timeout
~seconds:60.0
|> Event.map begin fun () ->
print_endline "Timeout";
Expand Down
3 changes: 3 additions & 0 deletions lib/picos_io.thread_atomic/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name picos_io_thread_atomic)
(package picos_io))
16 changes: 8 additions & 8 deletions lib/picos_stdio/dune → lib/picos_io/dune
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
(library
(name picos_stdio)
(public_name picos_stdio)
(name picos_io)
(public_name picos_io)
(root_module Deps)
(libraries
(re_export unix)
(re_export picos_stdio_fd)
(re_export picos)
(re_export picos_io_fd)
(re_export unix)
picos_aux.htbl
picos_stdio.select))
picos_io.select))

(mdx
(package picos_meta)
(enabled_if
(>= %{ocaml_version} 5.1.0))
(libraries
picos
picos_io
picos_mux.random
picos_std.finally
picos_std.structured
picos_stdio
unix)
(files picos_stdio.mli))
(files picos_io.mli))

(documentation
(package picos_stdio)
(package picos_io)
(mld_files index))
6 changes: 3 additions & 3 deletions lib/picos_stdio/index.mld → lib/picos_io/index.mld
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
This package provides an asynchronous IO system for {!Picos}.

{!modules:
Picos_stdio
Picos_stdio_select
Picos_stdio_fd
Picos_io
Picos_io_select
Picos_io_fd
}

{^ The IO libraries in this package are currently built only on top of the
Expand Down
4 changes: 2 additions & 2 deletions lib/picos_stdio/picos_stdio.ml → lib/picos_io/picos_io.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open Picos
module Select = Picos_stdio_select
module Fd = Picos_stdio_fd
module Select = Picos_io_select
module Fd = Picos_io_fd
module Htbl = Picos_aux_htbl

let nonblock_fds = Htbl.create ~hashed_type:(module Fd.Resource) ()
Expand Down
12 changes: 6 additions & 6 deletions lib/picos_stdio/picos_stdio.mli → lib/picos_io/picos_io.mli
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ module Unix : sig
Windows, scheduler friendly blocking only works properly with non-blocking
file descriptors, i.e. sockets.
⚠️ This module uses {!Picos_stdio_select} and you may need to
{{!Picos_stdio_select.configure} configure} it at start of your application.
⚠️ This module uses {!Picos_io_select} and you may need to
{{!Picos_io_select.configure} configure} it at start of your application.
Please consult the documentation of the {{!Deps.Unix} [Unix]} module that
comes with OCaml. *)

type file_descr = Picos_stdio_fd.t
type file_descr = Picos_io_fd.t
(** Opaque type alias for {{!Deps.Unix.file_descr} [Unix.file_descr]}.
⚠️ Please consider the reference counting of file descriptors as an
Expand Down Expand Up @@ -350,10 +350,10 @@ module Unix : sig
float ->
file_descr list * file_descr list * file_descr list
(** [select rds wrs exs timeout] is like {!Deps.Unix.select}, but uses
{!Picos_stdio_select} to avoid blocking the thread.
{!Picos_io_select} to avoid blocking the thread.
🐌 You may find composing multi file descriptor awaits via other means
with {!Picos_stdio_select} more flexible and efficient. *)
with {!Picos_io_select} more flexible and efficient. *)

type lock_command = Unix.lock_command =
| F_ULOCK
Expand Down Expand Up @@ -689,9 +689,9 @@ end
First we open some modules for convenience:
{[
open Picos_io
open Picos_std_finally
open Picos_std_structured
open Picos_stdio
]}
{2 A pair of pipes}
Expand Down
Loading

0 comments on commit 1f18591

Please sign in to comment.