Package org.agrona.concurrent
Class OneToOneConcurrentArrayQueue<E>
java.lang.Object
org.agrona.concurrent.AbstractConcurrentArrayQueuePadding1
org.agrona.concurrent.AbstractConcurrentArrayQueueProducer
org.agrona.concurrent.AbstractConcurrentArrayQueuePadding2
org.agrona.concurrent.AbstractConcurrentArrayQueueConsumer
org.agrona.concurrent.AbstractConcurrentArrayQueuePadding3
org.agrona.concurrent.AbstractConcurrentArrayQueue<E>
org.agrona.concurrent.OneToOneConcurrentArrayQueue<E>
- Type Parameters:
E- type of the elements stored in theQueue.
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Queue<E>,Pipe<E>,QueuedPipe<E>
One producer to one consumer concurrent queue that is array backed. The algorithm is a variation of Fast Flow
adapted to work with the Java Memory Model on arrays by using
Unsafe.-
Field Summary
Fields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueue
buffer, BUFFER_ARRAY_BASE, capacity, HEAD_OFFSET, SHARED_HEAD_CACHE_OFFSET, SHIFT_FOR_SCALE, TAIL_OFFSETFields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueuePadding3
p128, p129, p130, p131, p132, p133, p134, p135, p136, p137, p138, p139, p140, p142, p143, p144, p145, p146, p147, p148, p149, p150, p151, p152, p153, p154, p155, p156, p157, p158, p159, p160, p161, p162, p163, p164, p165, p166, p167, p168, p169, p170, p171, p172, p173, p174, p175, p176, p177, p178, p179, p180, p181, p182, p183, p184, p185, p186, p187, p189, p190, p191, p192, p193Fields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueueConsumer
headFields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueuePadding2
p064, p065, p066, p067, p068, p069, p070, p071, p072, p073, p074, p075, p076, p077, p078, p079, p080, p081, p082, p083, p084, p085, p086, p087, p088, p089, p090, p091, p092, p093, p094, p095, p096, p097, p098, p099, p100, p101, p102, p103, p104, p105, p106, p107, p108, p109, p110, p111, p112, p113, p114, p115, p116, p117, p118, p119, p120, p121, p122, p123, p124, p125, p126, p127Fields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueueProducer
headCache, sharedHeadCache, tailFields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueuePadding1
p000, p001, p002, p003, p004, p005, p006, p007, p008, p009, p010, p011, p012, p013, p014, p015, p016, p017, p018, p019, p020, p021, p022, p023, p024, p025, p026, p027, p028, p029, p030, p031, p032, p033, p034, p035, p036, p037, p038, p039, p040, p041, p042, p043, p044, p045, p046, p047, p048, p049, p050, p051, p052, p053, p054, p055, p056, p057, p058, p059, p060, p061, p062, p063 -
Constructor Summary
ConstructorsConstructorDescriptionOneToOneConcurrentArrayQueue(int requestedCapacity) Constructs queue with the requested capacity. -
Method Summary
Modifier and TypeMethodDescriptionintDrain the number of elements present in a collection at the time the operation starts.intDrain the minimum of a limit and the number of elements present in a collection at the time the operation starts.intdrainTo(Collection<? super E> target, int limit) Drain available elements into the providedCollectionup to a provided maximum limit of elements.booleanpoll()Methods inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueue
add, addAll, addedCount, capacity, clear, contains, containsAll, element, isEmpty, iterator, peek, remainingCapacity, remove, remove, removeAll, removedCount, retainAll, sequenceToBufferOffset, size, toArray, toArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
OneToOneConcurrentArrayQueue
public OneToOneConcurrentArrayQueue(int requestedCapacity) Constructs queue with the requested capacity.- Parameters:
requestedCapacity- of the queue.
-
-
Method Details
-
offer
-
poll
-
drain
Drain the number of elements present in a collection at the time the operation starts.If possible, implementations should use smart batching to best handle burst traffic.
- Parameters:
elementConsumer-Consumerfor processing elements.- Returns:
- the number of elements drained.
-
drain
Drain the minimum of a limit and the number of elements present in a collection at the time the operation starts.If possible, implementations should use smart batching to best handle burst traffic.
- Parameters:
elementConsumer-Consumerfor processing elements.limit- maximum number of elements to be drained in a drain operation.- Returns:
- the number of elements drained.
-
drainTo
Drain available elements into the providedCollectionup to a provided maximum limit of elements.If possible, implementations should use smart batching to best handle burst traffic.
- Parameters:
target- in to which elements are drained.limit- maximum number of elements to be drained in a drain operation.- Returns:
- the number of elements actually drained.
-