public class ThreadReceivePort<Message>
extends java.lang.Object
ReceivePort that can be used by threads (as opposed to fibers). Its methods do not
declare they throw SuspendExecution.| Constructor and Description |
|---|
ThreadReceivePort(ReceivePort<Message> p)
Creates a new convenience wrapper for using a
ReceivePort in a thread. |
| 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) |
int |
hashCode() |
boolean |
isClosed()
Tests whether the channel has been closed and no more messages await in the channel.
|
Message |
receive()
Retrieves a message from the channels, possibly blocking until one becomes available.
|
Message |
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.
|
java.lang.String |
toString() |
Message |
tryReceive()
Retrieves a message from the channel if one is available.
|
public ThreadReceivePort(ReceivePort<Message> p)
ReceivePort in a thread.p - the SendPort to wrap.public Message receive() throws java.lang.InterruptedException
null if the channel has been closed and no more messages await (see isClosed()).java.lang.InterruptedExceptionpublic Message receive(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
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 isClosed()), or if
the timeout has expired.java.lang.InterruptedExceptionpublic Message tryReceive()
null if one is not immediately available.public void close()
public boolean isClosed()
true all
future calls to receive() are guaranteed to return null, and calls to receive on a primitive channel
will throw an EOFException.true if the channels has been closed and no more messages will be received; false otherwise.public final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final java.lang.String toString()
toString in class java.lang.Object