add max_fds to nanoev core interface

This commit is contained in:
Simon Cruanes 2025-04-30 22:16:06 -04:00
parent 8de6936787
commit 7a0c3e1279
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
3 changed files with 10 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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;