eio
eio copied to clipboard
Feature request: Stream select
Thank you very much for your work on eio! I've thoroughly enjoyed working with it, despite being a newcomer to OCaml. Eio feels more advanced than the async frameworks in other languages I've used.
So far, I have been missing one feature: Waiting on multiple streams, which in languages like Go or Rust is called select. I've taken a look at the source code, but as a newbie I didn't want to charge ahead with some untenable solution (and besides, any possible implementation appeared non-trivial to me).
I don't have a specific API in mind, but something simple like
val select : ('a Stream.t * ('a -> 'b)) list -> 'b
to select between different channels producing items of the same type and permitting per-stream handling, or
val select2 : 'a Stream.t -> 'b Stream.t -> ('a, 'b) Either.t
for selecting between exactly two streams may already prove to be useful. I'd love to hear what you think.