Package org.agrona.concurrent
Class AbstractConcurrentArrayQueue<E>
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.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
Fields Modifier and Type Field Description protected E[]
buffer
Backing array.protected static int
BUFFER_ARRAY_BASE
Array base.protected int
capacity
Queue capacity.protected static long
HEAD_OFFSET
Offset of thehead
field.protected static long
SHARED_HEAD_CACHE_OFFSET
Offset of thesharedHeadCache
field.protected static int
SHIFT_FOR_SCALE
Shift for scale.protected static long
TAIL_OFFSET
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
Constructors Constructor Description AbstractConcurrentArrayQueue(int requestedCapacity)
Constructs a queue with the requested capacity.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E e)
boolean
addAll(java.util.Collection<? extends E> c)
long
addedCount()
The number of items added to this container since creation.int
capacity()
The maximum capacity of this container to hold items.void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
E
element()
boolean
isEmpty()
java.util.Iterator<E>
iterator()
E
peek()
int
remainingCapacity()
Get the remaining capacity for elements in the container given the current size.E
remove()
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
long
removedCount()
The number of items removed from this container since creation.boolean
retainAll(java.util.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.java.lang.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
-
-
-
-
Field Detail
-
TAIL_OFFSET
protected static final long TAIL_OFFSET
Offset of thetail
field.
-
SHARED_HEAD_CACHE_OFFSET
protected static final long SHARED_HEAD_CACHE_OFFSET
Offset of thesharedHeadCache
field.
-
HEAD_OFFSET
protected static final long HEAD_OFFSET
Offset of thehead
field.
-
BUFFER_ARRAY_BASE
protected static final int BUFFER_ARRAY_BASE
Array base.
-
SHIFT_FOR_SCALE
protected static final int SHIFT_FOR_SCALE
Shift for scale.
-
capacity
protected final int capacity
Queue capacity.
-
buffer
protected final E[] buffer
Backing array.
-
-
Method Detail
-
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.
-
add
public boolean add(E e)
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection<E>
-
iterator
public java.util.Iterator<E> iterator()
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray
in interfacejava.util.Collection<E>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfacejava.util.Collection<E>
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
remove
in interfacejava.util.Collection<E>
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
- Specified by:
containsAll
in interfacejava.util.Collection<E>
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
- Specified by:
addAll
in interfacejava.util.Collection<E>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAll
in interfacejava.util.Collection<E>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAll
in interfacejava.util.Collection<E>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<E>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Collection<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.
-
-