public class DelegatingReceivePort<T> extends java.lang.Object implements ReceivePort<T>, DelegatingEquals
ReceivePort.EOFException| Modifier and Type | Field and Description |
|---|---|
protected ReceivePort<T> |
target |
| Constructor and Description |
|---|
DelegatingReceivePort(ReceivePort<T> target) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the channel so that no more messages could be sent to it.
|
boolean |
equals(java.lang.Object obj)
The
equals method of a DelegatingEquals object, will usually be implemented thus: |
int |
hashCode() |
boolean |
isClosed()
Tests whether the channel has been closed and no more messages await in the channel.
|
T |
receive()
Retrieves a message from the channels, possibly blocking until one becomes available.
|
T |
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.
|
T |
receive(Timeout timeout)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
|
java.lang.String |
toString() |
T |
tryReceive()
Retrieves a message from the channel if one is available.
|
protected final ReceivePort<T> target
public DelegatingReceivePort(ReceivePort<T> target)
public T receive() throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<T>null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()).java.lang.InterruptedExceptionSuspendExecutionpublic T receive(long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<T>timeout - the maximum duration to block waiting for a message.unit - the time unit of the timeout.null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()), or if the timeout has expired.java.lang.InterruptedExceptionSuspendExecutionpublic T receive(Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<T>timeout - the method will not block for longer than the amount remaining in the Timeoutnull if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()), or if the timeout has expired.java.lang.InterruptedExceptionSuspendExecutionpublic T tryReceive()
ReceivePorttryReceive in interface ReceivePort<T>null if one is not immediately available.public void close()
PortAutoCloseableclose in interface PortAutoCloseableclose in interface java.lang.AutoCloseablepublic boolean isClosed()
PortAutoCloseabletrue all
future calls to receive are guaranteed to return null, and calls to receive on a primitive channel
will throw a EOFException.isClosed in interface PortAutoCloseabletrue if the channels has been closed and no more messages will be received; false otherwise.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
DelegatingEqualsequals method of a DelegatingEquals object, will usually be implemented thus:
boolean equals(Object o) {
if (o instanceof DelegatingEquals)
return o.equals(delegate);
else
return delegate.equals(o);
}equals in interface DelegatingEqualsequals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object