eve.rt.channel.broadcast

Broadcast channel for the EVE runtime.

A broadcast channel delivers every sent message to all registered receivers. Each receiver gets its own independent copy of the message stream. Receivers that are slow do not affect other receivers.

Types 2

A single receiver's subscription to a broadcast channel.

Each receiver has its own internal buffer of unconsumed messages. Messages are dropped when the buffer overflows (oldest dropped first).

Fields
T[] buffer
size_t head
size_t tail
size_t count
size_t capacity_
bool closed_
Mutex mutex
Methods
void push(T value) @trusted
ChannelStatus tryReceive(out T value) @trustedTry to receive a value without blocking.
ChannelStatus tryReceive(out T value, CancelToken token) @trusted
void close() @trustedClose this receiver, discarding buffered messages.
bool isClosed() @property @trusted
size_t length() @property @trusted
size_t capacity() @property const pure @safe nothrow @nogc
bool empty() @property @trusted
Constructors
this(size_t capacity)

Broadcast channel that delivers every message to all receivers.

Each call to subscribe creates a new receiver with its own buffer. When a value is sent via send, it is pushed into every active receiver's buffer. Slow receivers that overflow their buffer lose the oldest messages (drop-first policy).

Fields
BroadcastReceiver!T *[] receivers_
Mutex mutex
bool closed_
bool initialized_
Methods
void initialize() @trustedInitialize the broadcast channel.
BroadcastReceiver!T * subscribe(size_t capacity = 64) @trustedSubscribe a new receiver with the given per-receiver buffer capacity.
void unsubscribe(BroadcastReceiver!T * receiver) @trustedUnsubscribe a receiver.
ChannelStatus send(T value) @trustedSend a value to all subscribed receivers.
void close() @trustedClose the broadcast channel.
bool isClosed() @property @trusted
size_t receiverCount() @property @trusted