1234567891011121314151617181920212223242526272829303132open!CoremoduleUnix=Core_unixincludeAsync_kernel.Async_kernel_configletfile_descr_watcher=matchfile_descr_watcherwith|(Epoll|Select|Io_uring)asx->x|Epoll_if_timerfd->(* Without timerfd, epoll_wait(2) timeouts would have only millisecond precision. *)ifResult.is_okLinux_ext.Timerfd.createthenEpollelseSelect;;letmax_num_open_file_descrs=ifnot(Max_num_open_file_descrs.equalmax_num_open_file_descrsMax_num_open_file_descrs.default)thenmax_num_open_file_descrselse(matchfile_descr_watcherwith|Select->(* The maximum numeric value for a file descriptor watchable by [select] is limited
by [FD_SETSIZE], which happens to be 1024 on Linux. *)Max_num_open_file_descrs.create_exn1024|Epoll|Epoll_if_timerfd|Io_uring->Int.minMax_num_open_file_descrs.(default|>raw)(matchUnix.RLimit.(getnum_file_descriptors).maxwith|Infinity->Int.max_value|Limitint64->int64|>Int64.to_int_exn)|>Max_num_open_file_descrs.create_exn);;