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
private T[] buffer
private size_t head
private size_t tail
private size_t count
private size_t capacity_
private bool closed_
private Mutex mutex
Methods
private 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
private BroadcastReceiver!T *[] receivers_
private Mutex mutex
private bool closed_
private 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