Package org.agrona.concurrent
Class AbstractConcurrentArrayQueue<E>
- Type Parameters:
E
- type of the queue elements.
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Queue<E>
,Pipe<E>
,QueuedPipe<E>
- Direct Known Subclasses:
ManyToManyConcurrentArrayQueue
,ManyToOneConcurrentArrayQueue
,OneToOneConcurrentArrayQueue
public abstract class AbstractConcurrentArrayQueue<E>
extends AbstractConcurrentArrayQueuePadding3
implements QueuedPipe<E>
Left over immutable queue fields.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final E[]
Backing array.protected static final int
Array base.protected final int
Queue capacity.protected static final long
Offset of thehead
field.protected static final long
Offset of thesharedHeadCache
field.protected static final int
Shift for scale.protected static final long
Offset of thetail
field.Fields 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, p193
Fields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueueConsumer
head
Fields 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, p127
Fields inherited from class org.agrona.concurrent.AbstractConcurrentArrayQueueProducer
headCache, sharedHeadCache, tail
Fields 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
ConstructorsConstructorDescriptionAbstractConcurrentArrayQueue
(int requestedCapacity) Constructs a queue with the requested capacity. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) long
The number of items added to this container since creation.int
capacity()
The maximum capacity of this container to hold items.void
clear()
boolean
boolean
containsAll
(Collection<?> c) element()
boolean
isEmpty()
iterator()
peek()
int
Get the remaining capacity for elements in the container given the current size.remove()
boolean
boolean
removeAll
(Collection<?> c) long
The number of items removed from this container since creation.boolean
retainAll
(Collection<?> c) static long
sequenceToBufferOffset
(long sequence, long mask) Compute buffer offset based on the given sequence and the mask.int
size()
The number of items currently in the container.Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
TAIL_OFFSET
protected static final long TAIL_OFFSETOffset of thetail
field. -
SHARED_HEAD_CACHE_OFFSET
protected static final long SHARED_HEAD_CACHE_OFFSETOffset of thesharedHeadCache
field. -
HEAD_OFFSET
protected static final long HEAD_OFFSETOffset of thehead
field. -
BUFFER_ARRAY_BASE
protected static final int BUFFER_ARRAY_BASEArray base. -
SHIFT_FOR_SCALE
protected static final int SHIFT_FOR_SCALEShift for scale. -
capacity
protected final int capacityQueue capacity. -
buffer
Backing array.
-
-
Constructor Details
-
AbstractConcurrentArrayQueue
public AbstractConcurrentArrayQueue(int requestedCapacity) Constructs a queue with the requested capacity.- Parameters:
requestedCapacity
- of the queue.
-
-
Method Details
-
addedCount
public long addedCount()The number of items added to this container since creation.- Specified by:
addedCount
in interfacePipe<E>
- Returns:
- the number of items added.
-
removedCount
public long removedCount()The number of items removed from this container since creation.- Specified by:
removedCount
in interfacePipe<E>
- Returns:
- the number of items removed.
-
capacity
public int capacity()The maximum capacity of this container to hold items. -
remainingCapacity
public int remainingCapacity()Get the remaining capacity for elements in the container given the current size.- Specified by:
remainingCapacity
in interfacePipe<E>
- Returns:
- remaining capacity of the container.
-
peek
-
add
-
remove
-
element
-
contains
- Specified by:
contains
in interfaceCollection<E>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<E>
-
remove
- Specified by:
remove
in interfaceCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
-
size
public int size()The number of items currently in the container. -
sequenceToBufferOffset
public static long sequenceToBufferOffset(long sequence, long mask) Compute buffer offset based on the given sequence and the mask.- Parameters:
sequence
- to compute the offset from.mask
- to apply.- Returns:
- buffer offset.
-