zio.channel

package zio.channel

Members list

Type members

Classlikes

class Channel[A]

An implementation of a thread-safe, blocking channel.

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
Supertypes
class Object
trait Matchable
class Any
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.

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
Supertypes
class Object
trait Matchable
class Any
Self type
Channel.type
sealed trait ChannelStatus

A sealed trait representing the channel status.

A sealed trait representing the channel status.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Closed.type
object Open.type
object Closed extends ChannelStatus

Object representing a closed channel.

Object representing a closed channel.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Closed.type
object Open extends ChannelStatus

Object representing a open channel.

Object representing a open channel.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Open.type

Value members

Concrete methods

def foreverWhile[R, E](effect: ZIO[R, E, Boolean]): ZIO[R, E, Unit]

Runs the effect while the condition is true

Runs the effect while the condition is true

===Sample===

foreverWhile:
 for
   res <- ZIO.whenCaseZIO(channel.receive):
            case Right(data) =>
              Console.printLine(s"Received: $data") *> ZIO.succeed(true)
            case Left(Closed) =>
              Console.printLine(s"Channel closed") *> ZIO.succeed(false)
 yield res.get

Value parameters

effect

the effect to run that returns a boolean

Attributes

Returns

a ZIO that runs the effect forever while the condition is true