Channel.read

Read a message from the Channel with an optional timeout

Unbuffered mode:

If a writer is already blocked on the Channel, reader copies the value to output and wakes up the writer by yielding

If no writer is ready in the wait queue, reader appends itself to read wait queue and blocks

If channel is closed, it returns immediatly with a failure

Buffered mode:

If there are existing messages in the buffer, reader pops one off the buffer and returns immediatly with success, regardless of the Channel being closed or not

If there are no messages in the buffer it behaves exactly like the unbuffered operation

Param: output = Reference to output variable duration = Timeout duration

class Channel(T)
nothrow
bool
read
(
ref T output
,
Duration duration = Duration.init
)

Return Value

Type: bool

Success/Failure - Fails when channel is closed and there are no existing messages to be read. Fails when timeout is reached.

Meta