The current Polly.wait invokes a function f with every file descriptor that is ready to be processed. It assumes that these involcations are independent. To faciliate passing results from f back to the caller, introduce wait_fold:
val wait_fold :
t ( epoll *)
-> int (* max fds to handle )
-> int ( timeout in milliseconds: -1 = wait forever )
-> 'a ( initial value passed to f below *)
-> (t -> Unix.file_descr -> Events.t -> 'a -> 'a)
-> 'a
Function f receives as last argument a value and returns a value of the same type, which is passed to the next invocation of f. The value of the last invocation is returned by wait_fold. The first invocation of f receives a value provided as 4th argument to wait_fold by the caller.
To avoid allocating OCaml values, wait_fold does not return the number of file descriptors that were processed. But it would be possible to implement it using wait_fold.
The current Polly.wait invokes a function f with every file descriptor that is ready to be processed. It assumes that these involcations are independent. To faciliate passing results from f back to the caller, introduce wait_fold:
val wait_fold : t ( epoll *) -> int (* max fds to handle ) -> int ( timeout in milliseconds: -1 = wait forever ) -> 'a ( initial value passed to f below *) -> (t -> Unix.file_descr -> Events.t -> 'a -> 'a) -> 'a
Function f receives as last argument a value and returns a value of the same type, which is passed to the next invocation of f. The value of the last invocation is returned by wait_fold. The first invocation of f receives a value provided as 4th argument to wait_fold by the caller.
To avoid allocating OCaml values, wait_fold does not return the number of file descriptors that were processed. But it would be possible to implement it using wait_fold.
Signed-off-by: Christian Lindig christian.lindig@citrix.com