Package org.apache.beam.sdk.fn
Class CancellableQueue<T extends @NonNull Object>
java.lang.Object
org.apache.beam.sdk.fn.CancellableQueue<T>
A simplified
ThreadSafe blocking queue that can be cancelled freeing any blocked Threads and preventing future Threads from blocking.
The queue is able to be reset and re-used.
-
Constructor Summary
ConstructorsConstructorDescriptionCancellableQueue(int capacity) Creates aThreadSafeblocking queue with a maximum capacity. -
Method Summary
-
Constructor Details
-
CancellableQueue
public CancellableQueue(int capacity) Creates aThreadSafeblocking queue with a maximum capacity.
-
-
Method Details
-
put
Adds an element to this queue. Will block until the queue is not full or is cancelled.- Throws:
InterruptedException- if this thread was interrupted waiting to put the element. The caller must invokecancel(java.lang.Exception)if the interrupt is unrecoverable.Exception- if the queue is cancelled.
-
take
Takes an element from this queue. Will block until the queue is not full or is cancelled.- Throws:
InterruptedException- if this thread was interrupted waiting for an element. The caller must invokecancel(java.lang.Exception)if the interrupt is unrecoverable.Exception- if the queue is cancelled.
-
cancel
Causes any pending and futureput(T)andtake()invocations to throw an exception.The first call to
cancel(java.lang.Exception)sets the exception that will be thrown. Resetting the queue clears the exception. -
reset
public void reset()Enables the queue to be re-used after it has been cancelled.
-