Class DelegatingReceivePort<T>
- java.lang.Object
-
- co.paralleluniverse.strands.channels.DelegatingReceivePort<T>
-
- All Implemented Interfaces:
co.paralleluniverse.common.util.DelegatingEquals,Port<T>,PortAutoCloseable,ReceivePort<T>,java.lang.AutoCloseable
- Direct Known Subclasses:
TransformingReceivePort
public class DelegatingReceivePort<T> extends java.lang.Object implements ReceivePort<T>, co.paralleluniverse.common.util.DelegatingEquals
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface co.paralleluniverse.strands.channels.ReceivePort
ReceivePort.EOFException
-
-
Field Summary
Fields Modifier and Type Field Description protected ReceivePort<T>target
-
Constructor Summary
Constructors Constructor Description DelegatingReceivePort(ReceivePort<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.booleanequals(java.lang.Object obj)inthashCode()booleanisClosed()Tests whether the channel has been closed and no more messages await in the channel.Treceive()Retrieves a message from the channels, possibly blocking until one becomes available.Treceive(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.Treceive(Timeout timeout)Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.java.lang.StringtoString()TtryReceive()Retrieves a message from the channel if one is available.
-
-
-
Field Detail
-
target
protected final ReceivePort<T> target
-
-
Constructor Detail
-
DelegatingReceivePort
public DelegatingReceivePort(ReceivePort<T> target)
-
-
Method Detail
-
receive
public T receive() throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:ReceivePortRetrieves a message from the channels, possibly blocking until one becomes available.- Specified by:
receivein interfaceReceivePort<T>- Returns:
- a message, or
nullif the channel has been closed and no more messages await (seePortAutoCloseable.isClosed()). - Throws:
SuspendExecutionjava.lang.InterruptedException
-
receive
public T receive(long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:ReceivePortRetrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.- Specified by:
receivein interfaceReceivePort<T>- Parameters:
timeout- the maximum duration to block waiting for a message.unit- the time unit of the timeout.- Returns:
- a message, or
nullif the channel has been closed and no more messages await (seePortAutoCloseable.isClosed()), or if the timeout has expired. - Throws:
SuspendExecutionjava.lang.InterruptedException
-
receive
public T receive(Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
Description copied from interface:ReceivePortRetrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.- Specified by:
receivein interfaceReceivePort<T>- Parameters:
timeout- the method will not block for longer than the amount remaining in theTimeout- Returns:
- a message, or
nullif the channel has been closed and no more messages await (seePortAutoCloseable.isClosed()), or if the timeout has expired. - Throws:
SuspendExecutionjava.lang.InterruptedException
-
tryReceive
public T tryReceive()
Description copied from interface:ReceivePortRetrieves a message from the channel if one is available. This method never blocks.- Specified by:
tryReceivein interfaceReceivePort<T>- Returns:
- a message, or
nullif one is not immediately available.
-
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
-
isClosed
public boolean isClosed()
Description copied from interface:PortAutoCloseableTests whether the channel has been closed and no more messages await in the channel. If this method returnstrueall future calls toreceiveare guaranteed to returnnull, and calls toreceiveon a primitive channel will throw aEOFException.- Specified by:
isClosedin interfacePortAutoCloseable- Returns:
trueif the channels has been closed and no more messages will be received;falseotherwise.
-
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
-
-