@UnstableApi public final class MpscAtomicIntegerArrayQueue extends AtomicIntegerArray implements MpscIntQueue
| Constructor and Description |
|---|
MpscAtomicIntegerArrayQueue(int capacity,
int emptyValue)
Create a new queue instance of the given size.
|
| Modifier and Type | Method and Description |
|---|---|
int |
drain(int limit,
IntConsumer consumer)
Remove up to the given limit of elements from the queue, and pass them to the consumer in order.
|
int |
fill(int limit,
IntSupplier supplier)
Add up to the given limit of elements to this queue, from the given supplier.
|
boolean |
isEmpty()
Query if the queue is empty or not.
|
boolean |
offer(int value)
Offer the given value to the queue.
|
int |
poll()
Remove and return the next value from the queue, or return the "empty" value if the queue is empty.
|
int |
size()
Query the number of elements currently in the queue.
|
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, lazySet, length, set, toString, updateAndGet, weakCompareAndSetpublic MpscAtomicIntegerArrayQueue(int capacity,
int emptyValue)
Note: the size of the queue may be rounded up to nearest power-of-2.
capacity - The required fixed size of the queue.emptyValue - The special value that the queue should use to signal the "empty" case.
This value will be returned from poll() when the queue is empty,
and giving this value to offer(int) will cause an exception to be thrown.public boolean offer(int value)
MpscIntQueueoffer in interface MpscIntQueuevalue - The value to add to the queue.true if the value was added to the queue,
or false if the value could not be added because the queue is full.public int poll()
MpscIntQueuepoll in interface MpscIntQueuepublic int drain(int limit,
IntConsumer consumer)
MpscIntQueuedrain in interface MpscIntQueuelimit - The maximum number of elements to dequeue.consumer - The consumer to pass the removed elements to.public int fill(int limit,
IntSupplier supplier)
MpscIntQueuefill in interface MpscIntQueuelimit - The maximum number of elements to enqueue.supplier - The supplier to obtain the elements from.public boolean isEmpty()
MpscIntQueueThis method is inherently racy and the result may be out of date by the time the method returns.
isEmpty in interface MpscIntQueuetrue if the queue was observed to be empty, otherwise {@code false.public int size()
MpscIntQueueThis method is inherently racy and the result may be out of date by the time the method returns.
size in interface MpscIntQueueCopyright © 2008–2025 The Netty Project. All rights reserved.