mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
add Moonpool_io.main; make configure idempotent
This commit is contained in:
parent
65bc3c97ff
commit
9623e2d4b6
2 changed files with 15 additions and 2 deletions
|
|
@ -4,4 +4,4 @@
|
||||||
(synopsis "Async IO for moonpool, using Picos")
|
(synopsis "Async IO for moonpool, using Picos")
|
||||||
(enabled_if
|
(enabled_if
|
||||||
(>= %{ocaml_version} 5.0))
|
(>= %{ocaml_version} 5.0))
|
||||||
(libraries moonpool picos_io picos_io.select picos_io.fd))
|
(libraries moonpool moonpool.fib picos_io picos_io.select picos_io.fd))
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,20 @@ module Unix = Picos_io.Unix
|
||||||
module Select = Picos_io_select
|
module Select = Picos_io_select
|
||||||
|
|
||||||
let fd_of_unix_fd : Unix.file_descr -> Fd.t = Fun.id
|
let fd_of_unix_fd : Unix.file_descr -> Fd.t = Fun.id
|
||||||
let configure = Select.configure
|
|
||||||
|
open struct
|
||||||
|
let has_configured = Atomic.make false
|
||||||
|
end
|
||||||
|
|
||||||
|
let configure ?intr_sig ?handle_sigchld ?ignore_sigpipe () : unit =
|
||||||
|
if not (Atomic.exchange has_configured true) then
|
||||||
|
Select.configure ?intr_sig ?handle_sigchld ?ignore_sigpipe ()
|
||||||
|
|
||||||
|
(** [main f] runs [f()] inside a scheduler. *)
|
||||||
|
let main ?intr_sig ?handle_sigchld ?ignore_sigpipe (f : Moonpool.Runner.t -> 'a)
|
||||||
|
: 'a =
|
||||||
|
configure ?intr_sig ?handle_sigchld ?ignore_sigpipe ();
|
||||||
|
Moonpool_fib.main f
|
||||||
|
|
||||||
(** {2 Async read/write} *)
|
(** {2 Async read/write} *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue