ocaml-multicore / eio

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

Allow closing synchronous streams #641

Closed talex5 closed 9 months ago

talex5 commented 9 months ago

This isn't currently exposed in the public interface, but that could be done easily enough.

Need to decide how to indicate end-of-stream. This version has take return None, but that also means that take_nonblocking returns None for both no-item and closed-stream.

/cc @SGrondin This might be useful for #639.

SGrondin commented 9 months ago

This is great! It's something I need to port a major codebase to Eio and I can't be the only one. Good decision on [ `Would_block | `Closed].

Another useful and related feature is something similar to Lwt_stream.closed ('a t -> unit Lwt.t), it returns a promise that resolves once the stream is closed.

talex5 commented 9 months ago

Not sure about adding a closed promise. It's easy enough for users to do that themselves if they need it - it doesn't need any support from Eio.