T
- the value type to offer and poll, not nullpublic interface SimpleQueue<T>
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.
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all enqueued items from this queue.
|
boolean |
isEmpty()
Returns true if the queue is empty.
|
boolean |
offer(T value)
Atomically enqueue a single value.
|
boolean |
offer(T v1,
T v2)
Atomically enqueue two values.
|
T |
poll()
Tries to dequeue a value (non-null) or returns null if
the queue is empty.
|
boolean offer(@NonNull T value)
value
- the value to enqueue, not nullboolean offer(@NonNull T v1, @NonNull T v2)
v1
- the first value to enqueue, not nullv2
- the second value to enqueue, not null@Nullable T poll() throws Throwable
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.
Throwable
- if some pre-processing of the dequeued
item (usually through fused functions) throws.boolean isEmpty()
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).
void clear()