Package org.jctools.queues
Class IndexedQueueSizeUtil
- java.lang.Object
-
- org.jctools.queues.IndexedQueueSizeUtil
-
public final class IndexedQueueSizeUtil extends Object
A note to maintainers on index assumptions: in a single threaded world it would seem intuitive to assume:
As an invariant, but in a concurrent, long running settings all of the following need to be considered:producerIndex >= consumerIndex-
consumerIndex > producerIndex: due to counter overflow (unlikey with longs, but easy to reason) -
consumerIndex > producerIndex: due to consumer FastFlow like implementation discovering the element before the counter is updated. -
producerIndex - consumerIndex < 0: due to above. -
producerIndex - consumerIndex > Integer.MAX_VALUE: as linked buffers allow constructing queues with more thanInteger.MAX_VALUEelements.
-
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceIndexedQueueSizeUtil.IndexedQueue
-
Field Summary
Fields Modifier and Type Field Description static intIGNORE_PARITY_DIVISORstatic intPLAIN_DIVISOR
-
Constructor Summary
Constructors Constructor Description IndexedQueueSizeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisEmpty(IndexedQueueSizeUtil.IndexedQueue iq)static intsanitizedSize(int capacity, long size)static intsize(IndexedQueueSizeUtil.IndexedQueue iq, int divisor)
-
-
-
Field Detail
-
PLAIN_DIVISOR
public static final int PLAIN_DIVISOR
- See Also:
- Constant Field Values
-
IGNORE_PARITY_DIVISOR
public static final int IGNORE_PARITY_DIVISOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
size
public static int size(IndexedQueueSizeUtil.IndexedQueue iq, int divisor)
-
sanitizedSize
public static int sanitizedSize(int capacity, long size)
-
isEmpty
public static boolean isEmpty(IndexedQueueSizeUtil.IndexedQueue iq)
-
-