diff --git a/src/core/nanoev.ml b/src/core/nanoev.ml index c15935e..75d34b7 100644 --- a/src/core/nanoev.ml +++ b/src/core/nanoev.ml @@ -7,6 +7,7 @@ module Impl = struct clear: 'st -> unit; wakeup_from_outside: 'st -> unit; close: 'st -> Unix.file_descr -> unit; + max_fds: 'st -> int; on_readable: 'a 'b. 'st -> @@ -39,6 +40,7 @@ type t = Impl.t let[@inline] clear (Ev (ops, st)) = ops.clear st let[@inline] wakeup_from_outside (Ev (ops, st)) = ops.wakeup_from_outside st let[@inline] close (Ev (ops, st)) fd = ops.close st fd +let[@inline] max_fds (Ev (ops, st)) = ops.max_fds st let[@inline] on_readable (Ev (ops, st)) fd x y f : unit = ops.on_readable st fd x y f diff --git a/src/core/nanoev.mli b/src/core/nanoev.mli index 4792cd6..213b9de 100644 --- a/src/core/nanoev.mli +++ b/src/core/nanoev.mli @@ -9,6 +9,7 @@ module Impl : sig clear: 'st -> unit; wakeup_from_outside: 'st -> unit; close: 'st -> Unix.file_descr -> unit; + max_fds: 'st -> int; on_readable: 'a 'b. 'st -> @@ -43,6 +44,9 @@ val step : t -> unit val close : t -> Unix.file_descr -> unit (** Close the file descriptor and clean it up *) +val max_fds : t -> int +(** Maximum number of file descriptors that can be observed at once. *) + val on_readable : t -> Unix.file_descr -> 'a -> 'b -> (closed:bool -> 'a -> 'b -> unit) -> unit diff --git a/src/unix/nanoev_unix.ml b/src/unix/nanoev_unix.ml index 7d656c1..b74ea06 100644 --- a/src/unix/nanoev_unix.ml +++ b/src/unix/nanoev_unix.ml @@ -243,12 +243,16 @@ let step (self : st) : unit = () +(* limit for select is fixed and known *) +let max_fds _ = 1024 + let ops : st Nanoev.Impl.ops = { step; close; on_readable; on_writable; + max_fds; run_after_s; wakeup_from_outside; clear;