mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-13 14:30:32 -05:00
main module
This commit is contained in:
parent
9e2026e462
commit
57be8f2130
1 changed files with 16 additions and 57 deletions
|
|
@ -1,61 +1,20 @@
|
||||||
(*
|
(** {2 Re-exports} *)
|
||||||
(** Unix-compatible event loop *)
|
|
||||||
class type event_loop =
|
|
||||||
object
|
|
||||||
method one_step : block:bool -> unit -> unit
|
|
||||||
(** Run one step of the event loop.
|
|
||||||
@param block if [true], the call might block until the next timeout
|
|
||||||
or until the next IO event occurs. If [false], this does not
|
|
||||||
block and returns after having processed the available events. *)
|
|
||||||
|
|
||||||
method on_readable :
|
module Exn_bt = Moonpool.Exn_bt
|
||||||
Unix.file_descr -> (Cancel_handle.t -> unit) -> Cancel_handle.t
|
module Fiber = Moonpool_fib.Fiber
|
||||||
(** [on_readable fd f] creates a new event [ev], and will run [f ev] when
|
module FLS = Moonpool_fib.Fls
|
||||||
[fd] becomes readable *)
|
module Runner = Moonpool.Runner
|
||||||
|
module Ws_pool = Moonpool.Ws_pool
|
||||||
|
module Fifo_pool = Moonpool.Fifo_pool
|
||||||
|
module Fut = Moonpool.Fut
|
||||||
|
|
||||||
method on_writable :
|
(** {2 Event loop modules} *)
|
||||||
Unix.file_descr -> (Cancel_handle.t -> unit) -> Cancel_handle.t
|
|
||||||
|
|
||||||
method on_timer :
|
module Cancel_handle = Cancel_handle
|
||||||
float -> repeat:bool -> (Cancel_handle.t -> unit) -> Cancel_handle.t
|
module IO_in = IO_in
|
||||||
(** [on_timer delay ~repeat f] runs [f] after [delay].
|
module IO_out = IO_out
|
||||||
@param repeat if true runs [f] every [delay] seconds *)
|
include IO_unix
|
||||||
|
|
||||||
method fake_io : Unix.file_descr -> unit
|
let run_after_s = Ev_loop.run_after_s
|
||||||
(** Simulate activity on the FD *)
|
let run_every_s = Ev_loop.run_every_s
|
||||||
|
let main = Ev_loop.with_loop
|
||||||
method interrupt_if_in_blocking_section : unit
|
|
||||||
(** If run from inside the event loop when it's waiting, wakes the event loop up *)
|
|
||||||
|
|
||||||
method has_pending_tasks : bool
|
|
||||||
end
|
|
||||||
|
|
||||||
(* TODO: for lwt backend:
|
|
||||||
let has_pending_tasks (self : #t) : bool =
|
|
||||||
self#readable_count > 0 || self#writable_count > 0 || self#timer_count > 0
|
|
||||||
|
|
||||||
method readable_count : int
|
|
||||||
(** Number of events waiting for FDs to be readable FDs *)
|
|
||||||
|
|
||||||
method writable_count : int
|
|
||||||
|
|
||||||
method timer_count : int
|
|
||||||
(** Number of events waiting on a timer *)
|
|
||||||
let readable_count (self : #t) = self#readable_count
|
|
||||||
let writable_count (self : #t) = self#writable_count
|
|
||||||
let timer_count (self : #t) = self#timer_count
|
|
||||||
*)
|
|
||||||
|
|
||||||
let[@inline] one_step (self : #t) ~block () = self#one_step ~block ()
|
|
||||||
let[@inline] on_readable (self : #t) fd f = self#on_readable fd f
|
|
||||||
let[@inline] on_writable (self : #t) fd f = self#on_writable fd f
|
|
||||||
|
|
||||||
let[@inline] on_timer (self : #t) delay ~repeat f =
|
|
||||||
self#on_timer delay ~repeat f
|
|
||||||
|
|
||||||
let[@inline] fake_io (self : #t) fd = self#fake_io fd
|
|
||||||
let[@inline] has_pending_tasks (self : #t) = self#has_pending_tasks
|
|
||||||
|
|
||||||
let[@inline] interrupt_if_in_blocking_section (self : #t) : unit =
|
|
||||||
self#interrupt_if_in_blocking_section
|
|
||||||
*)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue