Channel

zio.channel.Channel
See theChannel companion class
object Channel

An implementation of a thread-safe, blocking channel. This is based on the Golang channels, Channel implementation in Stackless Python, and also on Erlang message passing with mailbox.

Effects can send messages to the queue using the send method, which will block until the message is received. Effects can also receive messages from the queue using the receive method, which will block until a message is available.

Type parameters

A

the type of messages in the queue

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Channel.type

Members list

Value members

Concrete methods

def make[A](capacity: Int): UIO[Channel[A]]

Creates a new instance of the Channel object. The capacity parameter determines the maximum number of messages that can be stored in the queue. If capacity is 0, the channel will block senders until message is received and block receivers until a message is sent.

Creates a new instance of the Channel object. The capacity parameter determines the maximum number of messages that can be stored in the queue. If capacity is 0, the channel will block senders until message is received and block receivers until a message is sent.

Type parameters

A

the type of messages in the queue

Value parameters

capacity

the maximum number of messages that can be stored in the queue

Attributes

Returns

a new instance of the Channel object

def make[A]: UIO[Channel[A]]

Creates a new instance of the Channel with capacity 0 which will block senders until message is received and block receivers until a message is sent.

Creates a new instance of the Channel with capacity 0 which will block senders until message is received and block receivers until a message is sent.

Type parameters

A

the type of messages in the queue

Attributes

Returns

a new instance of the Channel object

def select[A](head: Channel[A], tail: Channel[A]*): IO[ChannelStatus, A]

Select will take the first message from the first channel that is ready to be received and return it leaving the other channels untouched and ready for their own receive operation or a subsequent select operation. If no channels are ready, the effect will be blocked until a message is available.

Select will take the first message from the first channel that is ready to be received and return it leaving the other channels untouched and ready for their own receive operation or a subsequent select operation. If no channels are ready, the effect will be blocked until a message is available.

Value parameters

channels

the channels to select from

Attributes

Returns

a IO returning a message or a ZIO with errorChannelStatus