public BroadcastChannel<E> extends SendChannel<E>
Broadcast channel is a non-blocking primitive for communication between the sender and multiple receivers
that subscribe for the elements using BroadcastChannel.openSubscription
function and unsubscribe using ReceiveChannel.cancel
function.
See BroadcastChannel()
factory function for the description of available
broadcast channel implementations.
Note: This is an experimental api. It may be changed in the future updates.
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(java.lang.Throwable cause)
Cancels reception of remaining elements from this channel. This function closes the channel with
the specified cause (unless it was already closed), removes all buffered sent elements from it,
and
ReceiveChannel.cancel all open subscriptions.
This function returns true if the channel was not closed previously, or false otherwise. |
ReceiveChannel<E> |
openSubscription()
Subscribes to this
interface BroadcastChannel and returns a channel to receive elements from it.
The resulting channel shall be ReceiveChannel.cancel to unsubscribe from this
broadcast channel. |
close, getOnSend, invokeOnClose, isClosedForSend, isFull, offer, send
ReceiveChannel<E> openSubscription()
Subscribes to this interface BroadcastChannel
and returns a channel to receive elements from it.
The resulting channel shall be ReceiveChannel.cancel
to unsubscribe from this
broadcast channel.
interface BroadcastChannel
,
ReceiveChannel.cancel
boolean cancel(java.lang.Throwable cause)
Cancels reception of remaining elements from this channel. This function closes the channel with
the specified cause (unless it was already closed), removes all buffered sent elements from it,
and ReceiveChannel.cancel
all open subscriptions.
This function returns true
if the channel was not closed previously, or false
otherwise.
A channel that was cancelled with non-null cause is called a failed channel. Attempts to send or receive on a failed channel throw the specified cause exception.
ReceiveChannel.cancel