Class DelegatingSendPort<T>
- java.lang.Object
-
- co.paralleluniverse.strands.channels.DelegatingSendPort<T>
-
- All Implemented Interfaces:
co.paralleluniverse.common.util.DelegatingEquals,Port<T>,PortAutoCloseable,SendPort<T>,java.lang.AutoCloseable
- Direct Known Subclasses:
TransformingSendPort
public class DelegatingSendPort<T> extends java.lang.Object implements SendPort<T>, co.paralleluniverse.common.util.DelegatingEquals
-
-
Constructor Summary
Constructors Constructor Description DelegatingSendPort(SendPort<T> target)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the channel so that no more messages could be sent to it.voidclose(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.booleanequals(java.lang.Object obj)inthashCode()voidsend(T message)Sends a message to the channel, possibly blocking until there's room available in the channel.booleansend(T 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.booleansend(T 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.java.lang.StringtoString()booleantrySend(T message)Sends a message to the channel if the channel has room available.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface co.paralleluniverse.strands.channels.PortAutoCloseable
isClosed
-
-
-
-
Method Detail
-
send
public void send(T message) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:SendPortSends 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.- Specified by:
sendin interfaceSendPort<T>- Parameters:
message- the message- Throws:
SuspendExecutionjava.lang.InterruptedException
-
send
public boolean send(T message, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:SendPortSends 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.- Specified by:
sendin interfaceSendPort<T>- Parameters:
message- the messagetimeout- the maximum duration this method is allowed to wait.unit- the timeout's time unit- Returns:
trueif the message has been sent successfully;falseif the timeout has expired.- Throws:
SuspendExecutionjava.lang.InterruptedException
-
send
public boolean send(T message, Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:SendPortSends 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.- Specified by:
sendin interfaceSendPort<T>- Parameters:
message- the messagetimeout- the method will not block for longer than the amount remaining in theTimeout- Returns:
trueif the message has been sent successfully;falseif the timeout has expired.- Throws:
SuspendExecutionjava.lang.InterruptedException
-
trySend
public boolean trySend(T message)
Description copied from interface:SendPortSends a message to the channel if the channel has room available. This method never blocks.
-
close
public void close(java.lang.Throwable t)
Description copied from interface:SendPortCloses 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'sreceiveortryReceive, wrapped by aProducerException. Messages already sent to the channel prior to calling this method will still be received.
-
close
public void close()
Description copied from interface:PortAutoCloseableCloses the channel so that no more messages could be sent to it. Messages already sent to the channel will still be received.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacePortAutoCloseable
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfaceco.paralleluniverse.common.util.DelegatingEquals- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-