Interface SendPort<Message>
-
- All Superinterfaces:
java.lang.AutoCloseable
,Port<Message>
,PortAutoCloseable
- All Known Subinterfaces:
Channel<Message>
,DoubleChannel
,DoubleSendPort
,FloatChannel
,FloatSendPort
,IntChannel
,IntSendPort
,LongChannel
,LongSendPort
,StandardChannel<Message>
- All Known Implementing Classes:
ActorRef
,ActorRefDelegate
,Behavior
,DelegatingSendPort
,EventSource
,Mailbox
,QueueChannel
,QueueDoubleChannel
,QueueFloatChannel
,QueueIntChannel
,QueueLongChannel
,QueueObjectChannel
,QueuePrimitiveChannel
,Server
,SingleConsumerQueueChannel
,SplitSendPort
,Supervisor
,TimeoutChannel
,Topic
,TransferChannel
,TransformingSendPort
- 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 SendPort<Message> extends Port<Message>, PortAutoCloseable
A channel's producer-side functional interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close(java.lang.Throwable t)
Closes the channel so that no more messages could be sent to it, and signifies an exception occurred in the producer.default void
send(Message message)
Sends a message to the channel, possibly blocking until there's room available in the channel.boolean
send(Message message, long timeout, java.util.concurrent.TimeUnit unit)
Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout.default boolean
send(Message message, Timeout timeout)
Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout.default boolean
trySend(Message message)
Sends a message to the channel if the channel has room available.-
Methods inherited from interface co.paralleluniverse.strands.channels.PortAutoCloseable
close, isClosed
-
-
-
-
Method Detail
-
send
default void send(Message message) throws SuspendExecution, java.lang.InterruptedException
Sends a message to the channel, possibly blocking until there's room available in the channel. If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the channel'sOverflowPolicy
, set at construction time.- Parameters:
message
- the message- Throws:
SuspendExecution
java.lang.InterruptedException
-
send
boolean send(Message message, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout. If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the channel'sOverflowPolicy
, set at construction time.- Parameters:
message
- the messagetimeout
- the maximum duration this method is allowed to wait.unit
- the timeout's time unit- Returns:
true
if the message has been sent successfully;false
if the timeout has expired.- Throws:
SuspendExecution
java.lang.InterruptedException
-
send
default boolean send(Message message, Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the specified timeout. If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from the channel. The behavior is determined by the channel'sOverflowPolicy
, set at construction time.- Parameters:
message
- the messagetimeout
- the method will not block for longer than the amount remaining in theTimeout
- Returns:
true
if the message has been sent successfully;false
if the timeout has expired.- Throws:
SuspendExecution
java.lang.InterruptedException
-
trySend
default boolean trySend(Message message)
Sends a message to the channel if the channel has room available. This method never blocks.- Parameters:
message
- the message- Returns:
true
if the message has been sent;false
otherwise.
-
close
default void close(java.lang.Throwable t)
Closes the channel so that no more messages could be sent to it, and signifies an exception occurred in the producer. The exception will be thrown when the consumer callsReceivePort
'sreceive
ortryReceive
, wrapped by aProducerException
. Messages already sent to the channel prior to calling this method will still be received.- Parameters:
t
- the exception causing the close
-
-