Skip to main content

namespace Channel

A Rimbu Channel offers various ways to synchronize communication between asynchronous processes. These processes can send and receive messages in a blocking way. Channel messages are of type T, and channels can be buffered or unbuffered. A buffered channel can queue a given amount of messages before blocking the sender.

Companion interface: Channel<T>

Interfaces

NameDescription
Channel.ConfigThe configuration options for creating a Channel.
Channel.ConstructorsDefines the static Channel API.
Channel.Read<T>A read-only Channel that can perform blocking reads. This means that a receive call will block until a message is available.
Channel.Write<T>A write-only Channel that can perform blocking writes. This means that a send call will block until the channel has capacity to send a message.

Static Methods

create

Returns a new Channel instance that can be used to synchronize asynchronous processes within a single thread.

Definition

create<T = void>(options?: Channel.Config): Channel<T>;

Type parameters

NameDefaultDescription
Tvoidthe channel message type

Parameters

NameTypeDescription
optionsChannel.Config(optional) the options used to create the channel
- capacity: (optional) the buffer size of the channel
- validator: (optional) a function taking a message and returning true if the message is of a valid type, false otherwise