Hub

abstract class Hub[A] extends Enqueue[A]

A Hub is an asynchronous message hub. Publishers can offer messages to the hub and subscribers can subscribe to take messages from the hub.

Companion:
object
trait Enqueue[A]
class Object
trait Matchable
class Any

Value members

Abstract methods

def publish(a: A)(implicit trace: Trace): UIO[Boolean]

Publishes a message to the hub, returning whether the message was published to the hub.

Publishes a message to the hub, returning whether the message was published to the hub.

def publishAll[A1 <: A](as: Iterable[A1])(implicit trace: Trace): UIO[Chunk[A1]]

Publishes all of the specified messages to the hub, returning any messages that were not published to the hub.

Publishes all of the specified messages to the hub, returning any messages that were not published to the hub.

def subscribe(implicit trace: Trace): ZIO[Scope, Nothing, Dequeue[A]]

Subscribes to receive messages from the hub. The resulting subscription can be evaluated multiple times within the scope to take a message from the hub each time.

Subscribes to receive messages from the hub. The resulting subscription can be evaluated multiple times within the scope to take a message from the hub each time.

Concrete methods

final override def isEmpty(implicit trace: Trace): UIO[Boolean]
Definition Classes
final override def isFull(implicit trace: Trace): UIO[Boolean]
Definition Classes
final def offer(a: A)(implicit trace: Trace): UIO[Boolean]
final def offerAll[A1 <: A](as: Iterable[A1])(implicit trace: Trace): UIO[Chunk[A1]]

Inherited methods

def awaitShutdown(implicit trace: Trace): UIO[Unit]

Waits until the queue is shutdown. The IO returned by this method will not resume until the queue has been shutdown. If the queue is already shutdown, the IO will resume right away.

Waits until the queue is shutdown. The IO returned by this method will not resume until the queue has been shutdown. If the queue is already shutdown, the IO will resume right away.

Inherited from:
Enqueue

How many elements can hold in the queue

How many elements can hold in the queue

Inherited from:
Enqueue
def isShutdown(implicit trace: Trace): UIO[Boolean]

true if shutdown has been called.

true if shutdown has been called.

Inherited from:
Enqueue
def shutdown(implicit trace: Trace): UIO[Unit]

Interrupts any fibers that are suspended on offer or take. Future calls to offer* and take* will be interrupted immediately.

Interrupts any fibers that are suspended on offer or take. Future calls to offer* and take* will be interrupted immediately.

Inherited from:
Enqueue
def size(implicit trace: Trace): UIO[Int]

Retrieves the size of the queue, which is equal to the number of elements in the queue. This may be negative if fibers are suspended waiting for elements to be added to the queue.

Retrieves the size of the queue, which is equal to the number of elements in the queue. This may be negative if fibers are suspended waiting for elements to be added to the queue.

Inherited from:
Enqueue