- All Superinterfaces:
CloseableChannel
- All Known Implementing Classes:
Channel
A channel source, which can be used to receive values from the channel. See
Channel for more details.-
Method Summary
Modifier and TypeMethodDescriptiondefault voidInvokes the given function for each received element.receive()Receive a value from the channel.Create a clause which can be used inSelect.select(SelectClause[]).<U> SelectClause<U> receiveClause(Function<T, U> callback) Create a clause which can be used inSelect.select(SelectClause[]).Receive a value from the channel.toList()Accumulates all elements received from the channel into a list.Methods inherited from interface com.softwaremill.jox.CloseableChannel
closedForReceive, closedForSend, done, doneOrClosed, error, errorOrClosed, isClosedForReceive, isClosedForSend
-
Method Details
-
receive
Receive a value from the channel.- Throws:
ChannelClosedException- When the channel is closed.InterruptedException
-
receiveOrClosed
Receive a value from the channel. Doesn't throw exceptions when the channel is closed, but returns a value.- Returns:
- Either a value of type
T, orChannelClosed, when the channel is closed. - Throws:
InterruptedException
-
receiveClause
SelectClause<T> receiveClause()Create a clause which can be used inSelect.select(SelectClause[]). The clause will receive a value from the current channel. -
receiveClause
Create a clause which can be used inSelect.select(SelectClause[]). The clause will receive a value from the current channel, and transform it using the providedcallback. -
forEach
Invokes the given function for each received element. Blocks until the channel is done.- Throws:
ChannelErrorException- When there is an upstream error.InterruptedException
-
toList
Accumulates all elements received from the channel into a list. Blocks until the channel is done.- Throws:
ChannelErrorException- When there is an upstream error.InterruptedException
-