public class ValChannel<V> extends java.lang.Object implements ReceivePort<V>, Selectable<V>
ReceivePort.EOFException| Constructor and Description |
|---|
ValChannel(Val<V> val) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the channel so that no more messages could be sent to it.
|
boolean |
isClosed()
Tests whether the channel has been closed and no more messages await in the channel.
|
V |
receive()
Retrieves a message from the channels, possibly blocking until one becomes available.
|
V |
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.
|
V |
receive(Timeout timeout)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
|
java.lang.Object |
register(SelectAction<V> action1) |
boolean |
tryNow(java.lang.Object token) |
V |
tryReceive()
Retrieves a message from the channel if one is available.
|
void |
unregister(java.lang.Object token) |
public V receive() throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<V>null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()).java.lang.InterruptedExceptionSuspendExecutionpublic V tryReceive()
ReceivePorttryReceive in interface ReceivePort<V>null if one is not immediately available.public V receive(long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<V>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 V receive(Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<V>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 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 java.lang.Object register(SelectAction<V> action1)
register in interface Selectable<V>public boolean tryNow(java.lang.Object token)
tryNow in interface Selectable<V>public void unregister(java.lang.Object token)
unregister in interface Selectable<V>