Channel

A golang style channel implementation with buffered and unbuffered operation modes

Intended to be used between Fibers

Param: T = Type of the messages carried accross the Channel. Currently all reference and values types are supported.

Constructors

this
this(ulong max_size)

Constructs a Channel

Members

Functions

close
void close()

Close the channel

isClosed
bool isClosed()

Return the closed status of the Channel

length
size_t length()

Return the length of the internal buffer

read
bool read(T output, Duration duration)

Read a message from the Channel with an optional timeout

selectRead
void selectRead(void* ptr, SelectState sel_state, int sel_id)

Try to read a message from Channel without blocking and if it fails, create a read queue entry using the given sel_state and sel_id

selectWrite
void selectWrite(void* ptr, SelectState sel_state, int sel_id)

Try to write a message to Channel without blocking and if it fails, create a write queue entry using the given sel_state and sel_id

write
bool write(T val, Duration duration)

Write a message to the Channel with an optional timeout

Variables

max_size
ulong max_size;

Maximum amount of T a Channel can buffer

Inherited Members

From Selectable

selectWrite
void selectWrite(void* ptr, SelectState sel_state, int sel_id)
selectRead
void selectRead(void* ptr, SelectState sel_state, int sel_id)

Try to read/write to the Selectable without blocking. If the operation would block, queue and link it with the sel_state

Meta