std1.0.0-beta-7 SafeC docs

std :: sync::channel

Struct std::Chan

#include <std/sync/channel.h> source

generic<T: Send> struct Chan { }

Methods

§static struct Chan<T> new(int cap)source · definition

buffered channel of cap slots

§int send(T val)source · definition

1 on success, 0 if closed (or never created)

§?T recv()source · definition

null once closed and drained

§void close()source · definition

No more sends; wakes every blocked sender/receiver (receivers drain what is buffered first). The runtime channel itself is never freed (there is no destroy), so a Chan is not a Drop type.

§int enqueue(T val)source · definition

send/recv under the Fifo names (std/collections/traits.h), so generic producer/consumer code takes a Chan like any queue. Both block.

§?T dequeue()source · definition