@Internal public class OrderedStreamElementQueue extends Object implements StreamElementQueue
StreamElementQueue
implementation. The ordered stream element queue emits
asynchronous results in the order in which the StreamElementQueueEntry
have been added
to the queue. Thus, even if the completion order can be arbitrary, the output order strictly
follows the insertion order (element cannot overtake each other).Constructor and Description |
---|
OrderedStreamElementQueue(int capacity,
Executor executor,
OperatorActions operatorActions) |
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty()
True if the queue is empty; otherwise false.
|
AsyncResult |
peekBlockingly()
Peek at the head of the queue and return the first completed
AsyncResult . |
AsyncResult |
poll()
Poll the first completed
AsyncResult from the head of this queue. |
<T> void |
put(StreamElementQueueEntry<T> streamElementQueueEntry)
Put the given element in the queue if capacity is left.
|
int |
size()
Return the size of the queue.
|
<T> boolean |
tryPut(StreamElementQueueEntry<T> streamElementQueueEntry)
Try to put the given element in the queue.
|
Collection<StreamElementQueueEntry<?>> |
values()
Return the collection of
StreamElementQueueEntry currently contained in this queue. |
public OrderedStreamElementQueue(int capacity, Executor executor, OperatorActions operatorActions)
public AsyncResult peekBlockingly() throws InterruptedException
StreamElementQueue
AsyncResult
. This
operation is a blocking operation and only returns once a completed async result has been
found.peekBlockingly
in interface StreamElementQueue
AsyncResult
InterruptedException
- if the current thread has been interrupted while waiting for a
completed async result.public AsyncResult poll() throws InterruptedException
StreamElementQueue
AsyncResult
from the head of this queue. This operation is
blocking and only returns once a completed async result has been found.poll
in interface StreamElementQueue
AsyncResult
which has been removed from the queueInterruptedException
- if the current thread has been interrupted while waiting for a
completed async result.public Collection<StreamElementQueueEntry<?>> values() throws InterruptedException
StreamElementQueue
StreamElementQueueEntry
currently contained in this queue.values
in interface StreamElementQueue
StreamElementQueueEntry
.InterruptedException
- if the current thread has been interrupted while retrieving the
stream element queue entries of this queue.public boolean isEmpty()
StreamElementQueue
isEmpty
in interface StreamElementQueue
public int size()
StreamElementQueue
size
in interface StreamElementQueue
public <T> void put(StreamElementQueueEntry<T> streamElementQueueEntry) throws InterruptedException
StreamElementQueue
put
in interface StreamElementQueue
T
- Type of the entries future valuestreamElementQueueEntry
- to be put into the queueInterruptedException
- if the calling thread has been interrupted while waiting to
insert the given elementpublic <T> boolean tryPut(StreamElementQueueEntry<T> streamElementQueueEntry) throws InterruptedException
StreamElementQueue
tryPut
in interface StreamElementQueue
T
- Type of the entries future valuestreamElementQueueEntry
- to be insertedInterruptedException
- if the calling thread has been interrupted while waiting to
insert the given elementCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.