ocaml-multicore / eio

Effects-based direct-style IO for multicore OCaml
Other
548 stars 66 forks source link

Stream select #578

Open dermesser opened 1 year ago

dermesser commented 1 year ago

(for #577)

This is a proposal for a (simplistic) implementation of Stream.select, which permits watching multiple streams and returning the first item yielded by any of them. It works for the intended use case, although at this point there are two weaknesses, both due to the underlying implementation using Fiber.any:

Thanks for considering this - I'd be happy to hear proposals for making this functionality more general, or just not based on the Fiber functions which restrict what can be done here. So please consider it a starting point :-)