public class TickerChannelConsumer<Message> extends java.lang.Object implements ReceivePort<Message>, Selectable<Message>
ReceivePort which is a view of a ticker channel.
Each ticker-consumer will yield monotonic messages, namely no message will be received more than once, and the messages will be
received in the order they're sent, but if the consumer is too slow, messages could be lost.| Modifier and Type | Class and Description |
|---|---|
static class |
TickerChannelConsumer.TickerChannelFloatConsumer |
ReceivePort.EOFException| Modifier and Type | Method and Description |
|---|---|
protected void |
checkClosed() |
void |
close()
Closes the channel so that no more messages could be sent to it.
|
long |
getLastIndexRead() |
boolean |
hasMessage() |
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.
|
Message |
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<Message> action) |
boolean |
tryNow(java.lang.Object token) |
Message |
tryReceive()
Retrieves a message from the channel if one is available.
|
void |
unregister(java.lang.Object token) |
protected void checkClosed()
throws ReceivePort.EOFException
ReceivePort.EOFExceptionpublic boolean hasMessage()
public final long getLastIndexRead()
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 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<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>