E
- the type of elements in this queuepublic abstract class MpscLinkedQueue<E> extends BaseLinkedQueue<E>
MessagePassingQueue.Consumer<T>, MessagePassingQueue.ExitCondition, MessagePassingQueue.Supplier<T>, MessagePassingQueue.WaitStrategy
p01, p02, p03, p04, p05, p06, p07, p10, p11, p12, p13, p14, p15, p16, p17
C_NODE_OFFSET, consumerNode
P_NODE_OFFSET, producerNode
p00
UNBOUNDED_CAPACITY
Modifier | Constructor and Description |
---|---|
protected |
MpscLinkedQueue() |
Modifier and Type | Method and Description |
---|---|
int |
fill(MessagePassingQueue.Supplier<E> s)
Stuff the queue with elements from the supplier.
|
int |
fill(MessagePassingQueue.Supplier<E> s,
int limit)
Stuff the queue with up to limit elements from the supplier.
|
void |
fill(MessagePassingQueue.Supplier<E> s,
MessagePassingQueue.WaitStrategy wait,
MessagePassingQueue.ExitCondition exit)
Stuff the queue with elements from the supplier forever.
|
static <E> MpscLinkedQueue<E> |
newMpscLinkedQueue()
Construct the implementation based on availability of getAndSet intrinsic.
|
boolean |
offer(E e)
Called from a producer thread subject to the restrictions appropriate to the implementation and
according to the
Queue.offer(Object) interface. |
E |
peek()
Called from the consumer thread subject to the restrictions appropriate to the implementation and
according to the
Queue.peek() interface. |
E |
poll()
Called from the consumer thread subject to the restrictions appropriate to the implementation and
according to the
Queue.poll() interface. |
protected abstract LinkedQueueNode<E> |
xchgProducerNode(LinkedQueueNode<E> nextNode) |
capacity, drain, drain, drain, getSingleConsumerNodeValue, isEmpty, iterator, relaxedOffer, relaxedPeek, relaxedPoll, size, toString
lpConsumerNode, lvConsumerNode, spConsumerNode
lpProducerNode, lvProducerNode, spProducerNode
contains, containsAll, remove, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clear
public static <E> MpscLinkedQueue<E> newMpscLinkedQueue()
protected abstract LinkedQueueNode<E> xchgProducerNode(LinkedQueueNode<E> nextNode)
public final boolean offer(E e)
Queue.offer(Object)
interface.
IMPLEMENTATION NOTES:
Offer is allowed from multiple threads.
Offer allocates a new node and:
e
- not null, will throw NPE if it isMessagePassingQueue.offer(Object)
,
Queue.offer(java.lang.Object)
public final E poll()
Queue.poll()
interface.
IMPLEMENTATION NOTES:
Poll is allowed from a SINGLE thread.
Poll reads the next node from the consumerNode and:
MessagePassingQueue.poll()
,
Queue.poll()
public final E peek()
MessagePassingQueue
Queue.peek()
interface.public int fill(MessagePassingQueue.Supplier<E> s)
MessagePassingQueue
while(relaxedOffer(s.get());
There's no strong commitment to the queue being full at the end of a fill. Called from a
producer thread subject to the restrictions appropriate to the implementation.public int fill(MessagePassingQueue.Supplier<E> s, int limit)
MessagePassingQueue
for(int i=0; i < limit && relaxedOffer(s.get()); i++);
There's no strong commitment to the queue being full at the end of a fill. Called from a producer
thread subject to the restrictions appropriate to the implementation.public void fill(MessagePassingQueue.Supplier<E> s, MessagePassingQueue.WaitStrategy wait, MessagePassingQueue.ExitCondition exit)
MessagePassingQueue
int idleCounter = 0;
while (exit.keepRunning()) {
E e = s.get();
while (!relaxedOffer(e)) {
idleCounter = wait.idle(idleCounter);
continue;
}
idleCounter = 0;
}
Called from a producer thread subject to the restrictions appropriate to the implementation.