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 intArray base.protected final intQueue capacity.protected static final longOffset of theheadfield.protected static final longOffset of thesharedHeadCachefield.protected static final intShift for scale.protected static final longOffset of thetailfield.Fields inherited from class 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 AbstractConcurrentArrayQueueConsumer
headFields inherited from class 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 AbstractConcurrentArrayQueueProducer
headCache, sharedHeadCache, tailFields inherited from class 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 TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> c) longThe number of items added to this container since creation.intcapacity()The maximum capacity of this container to hold items.voidclear()booleanbooleancontainsAll(Collection<?> c) element()booleanisEmpty()iterator()peek()intGet the remaining capacity for elements in the container given the current size.remove()booleanbooleanremoveAll(Collection<?> c) longThe number of items removed from this container since creation.booleanretainAll(Collection<?> c) static longsequenceToBufferOffset(long sequence, long mask) Compute buffer offset based on the given sequence and the mask.intsize()The number of items currently in the container.Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
TAIL_OFFSET
protected static final long TAIL_OFFSETOffset of thetailfield. -
SHARED_HEAD_CACHE_OFFSET
protected static final long SHARED_HEAD_CACHE_OFFSETOffset of thesharedHeadCachefield. -
HEAD_OFFSET
protected static final long HEAD_OFFSETOffset of theheadfield. -
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:
addedCountin interfacePipe<E>- Returns:
- the number of items added.
-
removedCount
public long removedCount()The number of items removed from this container since creation.- Specified by:
removedCountin interfacePipe<E>- Returns:
- the number of items removed.
-
capacity
-
remainingCapacity
public int remainingCapacity()Get the remaining capacity for elements in the container given the current size.- Specified by:
remainingCapacityin interfacePipe<E>- Returns:
- remaining capacity of the container.
-
peek
-
add
-
remove
-
element
-
contains
- Specified by:
containsin interfaceCollection<E>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E>
-
remove
- Specified by:
removein interfaceCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>
-
addAll
- Specified by:
addAllin interfaceCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>
-
size
-
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.
-