Channel

zio.channel.Channel
See theChannel companion object
class Channel[A]

An implementation of a thread-safe, blocking channel.

Type parameters

A

the type of messages in the queue

Value parameters

capacity

the capacity of the channel

done

a promise that is completed when the channel is closed

nonEmpty

a ref that allows us to wait for the possibility of a successful receive

queue

the underlying queue used to store messages

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def close: UIO[ChannelStatus]

Closes the channel, removing any pending messages and unblocking all waiting fibers.

Closes the channel, removing any pending messages and unblocking all waiting fibers.

Attributes

Returns

a UIO[Closed] representing the completion of the close operation

def receive: IO[ChannelStatus, A]

Receives a message from the queue, If no message is available, block until a message is available or the channel closes.

Receives a message from the queue, If no message is available, block until a message is available or the channel closes.

Attributes

Returns

a IO containing a message or fail with ChannelStatus.Closed

def send(a: A): IO[ChannelStatus, Unit]

Sends a message to the channel and blocks until the message is received by some fiber or the channel closes.

Sends a message to the channel and blocks until the message is received by some fiber or the channel closes.

Value parameters

a

the message to send

Attributes

Returns

a UIO representing the completion of the send operation

def status: IO[ChannelStatus, Int]

Returns the current status of the channel. If the channel is closed, the returned error will be Closed. Otherwise, the returned value will be an Int with the size, where size is the number of messages in the queue.

Returns the current status of the channel. If the channel is closed, the returned error will be Closed. Otherwise, the returned value will be an Int with the size, where size is the number of messages in the queue.

Attributes

Returns

an Int representing the current status of the channel