package eio
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=7d70d1f5fb2b7190bf1ab28fffeb272da51ffe6d6c9c7c94e0485fabdf3b3fda
sha512=4582ac2fb2f8616b3d8ae9670eb7913a78085899b14044408801b30a34fed6c4d32971ba72eedb0cbc3d82c057610cf81c482090e75e2985330fcde96478ac5e
doc/eio/Eio/Stream/index.html
Module Eio.StreamSource
A stream/queue.
Reading from an empty queue will wait until an item is available. Writing to a full queue will wait until there is space.
Example:
let t = Stream.create 100 in
Stream.add t 1;
Stream.add t 2;
assert (Stream.take t = 1);
assert (Stream.take t = 2)Streams are thread-safe and so can be shared between domains and used to communicate between them.
A queue of items of type 'a.
create capacity is a new stream which can hold up to capacity items without blocking writers.
- If
capacity = 0then writes block until a reader is ready. - If
capacity = 1then this acts as a "mailbox". - If
capacity = max_intthen the stream is effectively unbounded.
add t item adds item to t.
If this would take t over capacity, it blocks until there is space.
take t takes the next item from the head of t.
If no items are available, it waits until one becomes available.
take_nonblocking t is like Some (take t) except that it returns None if the stream is empty rather than waiting.
Note that if another domain may add to the stream then a None result may already be out-of-date by the time this returns.