Interface ReceivePort<Message>
-
- All Superinterfaces:
java.lang.AutoCloseable
,Port<Message>
,PortAutoCloseable
- All Known Subinterfaces:
Channel<Message>
,DoubleChannel
,DoubleReceivePort
,FloatChannel
,FloatReceivePort
,IntChannel
,IntReceivePort
,LongChannel
,LongReceivePort
,Mix<M>
,StandardChannel<Message>
- All Known Implementing Classes:
Actor
,BasicActor
,BehaviorActor
,DelegatingReceivePort
,EventSourceActor
,FiniteStateMachineActor
,FlatMappingReceivePort
,Mailbox
,ProxyServerActor
,QueueChannel
,QueueDoubleChannel
,QueueFloatChannel
,QueueIntChannel
,QueueLongChannel
,QueueObjectChannel
,QueuePrimitiveChannel
,ReceivePortGroup
,ServerActor
,SingleConsumerQueueChannel
,SupervisorActor
,TickerChannelConsumer
,TickerChannelConsumer.TickerChannelFloatConsumer
,TimeoutChannel
,TransferChannel
,TransformingReceivePort
,ValChannel
,ZippingReceivePort
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ReceivePort<Message> extends Port<Message>, PortAutoCloseable
A channel's consumer-side functional interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ReceivePort.EOFException
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Message
receive()
Retrieves a message from the channels, possibly blocking until one becomes available.Message
receive(long timeout, java.util.concurrent.TimeUnit unit)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.default Message
receive(Timeout timeout)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.default Message
tryReceive()
Retrieves a message from the channel if one is available.-
Methods inherited from interface co.paralleluniverse.strands.channels.PortAutoCloseable
close, isClosed
-
-
-
-
Method Detail
-
receive
default Message receive() throws SuspendExecution, java.lang.InterruptedException
Retrieves a message from the channels, possibly blocking until one becomes available.- Returns:
- a message, or
null
if the channel has been closed and no more messages await (seePortAutoCloseable.isClosed()
). - Throws:
java.lang.InterruptedException
SuspendExecution
-
receive
Message receive(long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.- Parameters:
timeout
- the maximum duration to block waiting for a message.unit
- the time unit of the timeout.- Returns:
- a message, or
null
if the channel has been closed and no more messages await (seePortAutoCloseable.isClosed()
), or if the timeout has expired. - Throws:
java.lang.InterruptedException
SuspendExecution
-
receive
default Message receive(Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.- Parameters:
timeout
- the method will not block for longer than the amount remaining in theTimeout
- Returns:
- a message, or
null
if the channel has been closed and no more messages await (seePortAutoCloseable.isClosed()
), or if the timeout has expired. - Throws:
java.lang.InterruptedException
SuspendExecution
-
tryReceive
default Message tryReceive()
Retrieves a message from the channel if one is available. This method never blocks.- Returns:
- a message, or
null
if one is not immediately available.
-
-