Library / Concurrency / Communication / Channel
Channel
Typed, bounded, point-to-point message channel.
Constructors 1
INIT(int64 capacity, BackpressurePolicy policy)
Methods 7
MODIFY METHOD send(T value) RETURNS STATUSmodifies
PUBLIC API
Enqueue value. Pipe-XOR STATUS. The bare-named (owning) form
consumes the source — the value is moved into the buffer. At
capacity, behaviour follows the BackpressurePolicy. Returns
FAILURE if the channel is closed.
MODIFY METHOD receive() RETURNS | Tmodifies
Remove and return the front value. Pipe-XOR: SUCCESS populates
value; blocks while the buffer is empty and the channel is
open. Returns FAILURE once the channel is closed AND drained, so
a WHILE ch->receive() DO { … } loop terminates on close.
MODIFY METHOD tryReceive() RETURNS | Tmodifies
Non-blocking receive. Pipe-XOR: SUCCESS returns the front value if
one is buffered; FAILURE immediately if the buffer is empty (never
blocks). A WHILE ch->tryReceive() DO { … } loop drains whatever
is currently buffered and then exits.
MODIFY METHOD close() RETURNS voidmodifies
Sticky shutdown. Wakes every blocked sender and receiver so they re-test their predicate and exit. Idempotent.
METHOD isClosed() RETURNS booleanreads
Non-blocking state read. TRUE once close() (or scope-exit CLEANUP) has run.
METHOD size() RETURNS int64reads
Current buffered count. Snapshot under the lock — advisory only (the value may change the instant the lock is released).