@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, weakCompareAndSet
public 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)
MpscIntQueue
offer
in interface MpscIntQueue
value
- 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()
MpscIntQueue
poll
in interface MpscIntQueue
public int drain(int limit, IntConsumer consumer)
MpscIntQueue
drain
in interface MpscIntQueue
limit
- The maximum number of elements to dequeue.consumer
- The consumer to pass the removed elements to.public int fill(int limit, IntSupplier supplier)
MpscIntQueue
fill
in interface MpscIntQueue
limit
- The maximum number of elements to enqueue.supplier
- The supplier to obtain the elements from.public boolean isEmpty()
MpscIntQueue
This method is inherently racy and the result may be out of date by the time the method returns.
isEmpty
in interface MpscIntQueue
true
if the queue was observed to be empty, otherwise {@code false.public int size()
MpscIntQueue
This method is inherently racy and the result may be out of date by the time the method returns.
size
in interface MpscIntQueue
Copyright © 2008–2025 The Netty Project. All rights reserved.