public abstract class QueueChannel<Message> extends java.lang.Object implements StandardChannel<Message>, Selectable<Message>, Synchronization, java.io.Serializable
ReceivePort.EOFException| Modifier and Type | Field and Description |
|---|---|
static FlightRecorder |
RECORDER |
| Modifier | Constructor and Description |
|---|---|
protected |
QueueChannel(BasicQueue<Message> queue,
Channels.OverflowPolicy overflowPolicy,
boolean singleConsumer) |
protected |
QueueChannel(BasicQueue<Message> queue,
Channels.OverflowPolicy overflowPolicy,
boolean singleProducer,
boolean singleConsumer) |
| 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) |
protected java.lang.Throwable |
getCloseException() |
Channels.OverflowPolicy |
getOverflowPolicy() |
int |
getQueueLength() |
boolean |
isClosed()
This method must only be called by the channel's owner (the receiver)
|
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.
|
Message |
receiveFromThread() |
Message |
receiveFromThread(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 |
send0(Message message,
boolean sync,
boolean timed,
long nanos) |
void |
sendNonSuspendable(Message message) |
protected void |
sendSync(Message message) |
protected void |
signalAndWait() |
protected void |
signalReceivers() |
protected Condition |
sync() |
java.lang.String |
toString() |
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) |
protected java.lang.Object |
writeReplace() |
public static final FlightRecorder RECORDER
protected QueueChannel(BasicQueue<Message> queue, Channels.OverflowPolicy overflowPolicy, boolean singleConsumer)
protected QueueChannel(BasicQueue<Message> queue, Channels.OverflowPolicy overflowPolicy, boolean singleProducer, boolean singleConsumer)
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic 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 Channels.OverflowPolicy getOverflowPolicy()
protected Condition sync()
protected void signalReceivers()
protected void signalAndWait()
throws SuspendExecution,
java.lang.InterruptedException
SuspendExecutionjava.lang.InterruptedExceptionpublic java.lang.Object register(SelectAction<Message> action)
register in interface Selectable<Message>public java.lang.Object register()
register in interface Synchronizationpublic 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 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)
SendPortprotected void sendSync(Message message) throws SuspendExecution
SuspendExecutionpublic boolean send0(Message message, boolean sync, boolean timed, long nanos) throws SuspendExecution, java.lang.InterruptedException
SuspendExecutionjava.lang.InterruptedExceptionpublic 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 void sendNonSuspendable(Message message) throws QueueCapacityExceededException
QueueCapacityExceededExceptionpublic boolean isClosed()
isClosed in interface PortAutoCloseabletrue if the channels has been closed and no more messages will be received; false otherwise.protected java.lang.Throwable getCloseException()
public Message tryReceive()
ReceivePorttryReceive in interface ReceivePort<Message>null if one is not immediately available.public 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.InterruptedExceptionSuspendExecutionpublic 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 Message receiveFromThread() throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic Message receiveFromThread(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic int getQueueLength()
public java.lang.String toString()
toString in class java.lang.Objectprotected java.lang.Object writeReplace()
throws java.io.ObjectStreamException
java.io.ObjectStreamException