Interface SimpleQueue<T>
- Type Parameters:
T- the value type to offer and poll, not null
- All Known Subinterfaces:
QueueDisposable<T>, QueueFuseable<T>, QueueSubscription<T>, SimplePlainQueue<T>
- All Known Implementing Classes:
SpscArrayQueue, SpscLinkedArrayQueue
public interface SimpleQueue<@NonNull T>
A simplified interface for offering, polling and clearing a queue.
This interface does not define most of the Collection
or Queue methods as the intended usage of SimpleQueue
does not require support for iteration or introspection.
- Since:
- 3.1.1
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all enqueued items from this queue.booleanisEmpty()Returns true if the queue is empty.booleanAtomically enqueue a single value.booleanAtomically enqueue two values.poll()Tries to dequeue a value (non-null) or returns null if the queue is empty.
-
Method Details
-
offer
-
offer
-
poll
Tries to dequeue a value (non-null) or returns null if the queue is empty.If the producer uses
offer(Object, Object)and when polling in pairs, if the first poll() returns a non-null item, the second poll() is guaranteed to return a non-null item as well.- Returns:
- the item or null to indicate an empty queue
- Throws:
Throwable- if some pre-processing of the dequeued item (usually through fused functions) throws.
-
isEmpty
boolean isEmpty()Returns true if the queue is empty.Note however that due to potential fused functions in
poll()it is possible this method returns false but then poll() returns null because the fused function swallowed the available item(s).- Returns:
- true if the queue is empty
-
clear
void clear()Removes all enqueued items from this queue.
-