public class TransferChannel<Message> extends java.lang.Object implements StandardChannel<Message>, Selectable<Message>, Synchronization
ReceivePort.EOFException| Constructor and Description |
|---|
TransferChannel() |
| Modifier and Type | Method and Description |
|---|---|
int |
capacity()
The channel's internal buffer capacity.
|
void |
close()
Closes the channel so that no more messages could be sent to it.
|
void |
close(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.
|
boolean |
equals(java.lang.Object other) |
int |
getWaitingConsumerCount() |
boolean |
isClosed()
Tests whether the channel has been closed and no more messages await in the channel.
|
boolean |
isSingleConsumer()
Whether or not the channel supports a single consumer only.
|
boolean |
isSingleProducer()
Whether or not the channel supports a single producer only.
|
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.
|
Message |
receive(Timeout timeout)
Retrieves a message from the channels, possibly blocking until one becomes available, but no longer than the specified timeout.
|
protected Message |
receiveInternal(long timeout,
java.util.concurrent.TimeUnit unit) |
java.lang.Object |
register() |
java.lang.Object |
register(SelectAction<Message> action) |
void |
send(Message message)
Sends a message to the channel, possibly blocking until there's room available in the channel.
|
boolean |
send(Message 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.
|
boolean |
send(Message 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.
|
boolean |
tryNow(java.lang.Object token) |
Message |
tryReceive()
Retrieves a message from the channel if one is available.
|
boolean |
trySend(Message message)
Sends a message to the channel if the channel has room available.
|
void |
unregister(java.lang.Object token) |
public final int capacity()
StandardChannelcapacity in interface StandardChannel<Message>-1 for an unbounded buffer, and 0 for a transfer channel.public boolean isSingleProducer()
StandardChannelisSingleProducer in interface StandardChannel<Message>true if the channel supports no more than one producer; false otherwise.public boolean isSingleConsumer()
StandardChannelisSingleConsumer in interface StandardChannel<Message>true if the channel supports no more than one consumer; false otherwise.public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic void send(Message message) throws SuspendExecution, java.lang.InterruptedException
SendPortOverflowPolicy, set at construction time.send in interface SendPort<Message>java.lang.InterruptedExceptionSuspendExecutionpublic boolean send(Message message, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
SendPortOverflowPolicy, set at construction time.send in interface SendPort<Message>timeout - the maximum duration this method is allowed to wait.unit - the timeout's time unittrue if the message has been sent successfully; false if the timeout has expired.SuspendExecutionjava.lang.InterruptedExceptionpublic boolean send(Message message, Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
SendPortOverflowPolicy, set at construction time.send in interface SendPort<Message>timeout - the method will not block for longer than the amount remaining in the Timeouttrue if the message has been sent successfully; false if the timeout has expired.SuspendExecutionjava.lang.InterruptedExceptionpublic boolean trySend(Message message)
SendPortpublic void close()
PortAutoCloseableclose in interface PortAutoCloseableclose in interface java.lang.AutoCloseablepublic void close(java.lang.Throwable t)
SendPortReceivePort's receive or tryReceive,
wrapped by a ProducerException.
Messages already sent to the channel prior to calling this method will still be received.public Message tryReceive()
ReceivePorttryReceive in interface ReceivePort<Message>null if one is not immediately available.public java.lang.Object register()
register in interface Synchronizationpublic java.lang.Object register(SelectAction<Message> action)
register in interface Selectable<Message>public boolean tryNow(java.lang.Object token)
tryNow in interface Selectable<Message>public void unregister(java.lang.Object token)
unregister in interface Selectable<Message>unregister in interface Synchronizationpublic Message receive() throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<Message>null if the channel has been closed and no more messages await (see PortAutoCloseable.isClosed()).java.lang.InterruptedExceptionSuspendExecutionprotected Message receiveInternal(long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
SuspendExecutionjava.lang.InterruptedExceptionpublic Message receive(long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<Message>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 Message receive(Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
ReceivePortreceive in interface ReceivePort<Message>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 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 getWaitingConsumerCount()