Non-blocking version of BaseReadableChannel.read. Unlike
ReadableChannel.read, if channel has no values, returns undefined
This means undefined
is returned in two cases: (1) the channel is open
but has no values, and the channel is closed and has no values. Use
ReadableChannel.closed to tell those apart
Blocks until the channel is "readable", meaning that it either:
Intuitively, when a channel is "readable", the next ReadableChannel.read call on it will not block
Note: in combination with ReadableChannel.tryRead, used to implement select
Specify value that will be returned once the wait unblocks
Optional
signal: AbortSignalUse the signal to cancel the wait. This frees up memory occupied by it. After cancelling, the wait will throw AbortedError
Reads a value from the channel. If there are no values, blocks until there is
If channel is buffered, takes next value from the buffer. This unblocks first of blocked WritableChannel.write calls if there are any
If channel is unbuffered, simply unblocks the first of blocked WritableChannel.write
If the channel is closed and has no values left in the buffer, returns
undefined
Concurrent calls are allowed - each read will get own value (no two reads will get the same value). If multiple calls are blocked, they will unblock one-by-one in unspecified order