T - The type of the items in the queue.public class BlockingDrainingQueue<T>
extends java.lang.Object
| Constructor and Description |
|---|
BlockingDrainingQueue()
Creates a new instance of the BlockingDrainingQueue class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(T item)
Adds a new item to the queue.
|
void |
cancelPendingTake()
Cancels any pending Future from a take() operation.
|
java.util.Queue<T> |
close()
Closes the queue and prevents any other access to it.
|
java.util.Queue<T> |
poll(int maxCount)
Returns the next items from the queue, if any.
|
int |
size()
Gets a value indicating the size of this queue.
|
java.util.concurrent.CompletableFuture<java.util.Queue<T>> |
take(int maxCount)
Returns the next items from the queue.
|
public BlockingDrainingQueue()
public java.util.Queue<T> close()
public void cancelPendingTake()
public void add(T item)
item - The item to add.ObjectClosedException - If the Queue is closed.public java.util.Queue<T> poll(int maxCount)
maxCount - The maximum number of items to return.java.lang.IllegalStateException - If there is a pending take() operation which hasn't completed yet.public java.util.concurrent.CompletableFuture<java.util.Queue<T>> take(int maxCount)
maxCount - The maximum number of items to return. This argument will be ignored if the queue is currently empty,
but in that case the result will always be completed with exactly one element.ObjectClosedException - If the Queue is closed.java.lang.IllegalStateException - If another call to take() is in progress.public int size()