Package org.jctools.queues
Class SpscOffHeapIntQueue
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<java.lang.Integer>
-
- org.jctools.queues.SpscOffHeapIntQueue
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Integer>,java.util.Collection<java.lang.Integer>,java.util.Queue<java.lang.Integer>
public final class SpscOffHeapIntQueue extends java.util.AbstractQueue<java.lang.Integer>
-
-
Field Summary
Fields Modifier and Type Field Description private longarrayBaseprivate java.nio.ByteBufferbuffyprivate intcapacitystatic byteCONSUMERprivate longheadAddressprivate longheadCacheAddressstatic intINT_ELEMENT_SCALEprivate intmaskstatic bytePRODUCERprivate longtailAddressprivate longtailCacheAddress
-
Constructor Summary
Constructors Constructor Description SpscOffHeapIntQueue(int capacity)SpscOffHeapIntQueue(java.nio.ByteBuffer buff, int capacity, byte viewMask)This is to be used for an IPC queue with the direct buffer used being a memory mapped file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private longcalcElementOffset(long currentHead)private longgetHead()private longgetHeadCache()private longgetHeadPlain()static intgetRequiredBufferSize(int capacity)private longgetTail()private longgetTailCache()private longgetTailPlain()booleanisEmpty()java.util.Iterator<java.lang.Integer>iterator()booleanoffer(java.lang.Integer e)booleanofferInt(int e)java.lang.Integerpeek()intpeekInt()java.lang.Integerpoll()intpollInt()private voidsetHead(long value)private voidsetHeadCache(long value)private voidsetTail(long value)private voidsetTailCache(long value)intsize()-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
PRODUCER
public static final byte PRODUCER
- See Also:
- Constant Field Values
-
CONSUMER
public static final byte CONSUMER
- See Also:
- Constant Field Values
-
INT_ELEMENT_SCALE
public static final int INT_ELEMENT_SCALE
-
buffy
private final java.nio.ByteBuffer buffy
-
headAddress
private final long headAddress
-
tailCacheAddress
private final long tailCacheAddress
-
tailAddress
private final long tailAddress
-
headCacheAddress
private final long headCacheAddress
-
capacity
private final int capacity
-
mask
private final int mask
-
arrayBase
private final long arrayBase
-
-
Constructor Detail
-
SpscOffHeapIntQueue
public SpscOffHeapIntQueue(int capacity)
-
SpscOffHeapIntQueue
public SpscOffHeapIntQueue(java.nio.ByteBuffer buff, int capacity, byte viewMask)This is to be used for an IPC queue with the direct buffer used being a memory mapped file.- Parameters:
buff-capacity-viewMask-
-
-
Method Detail
-
getRequiredBufferSize
public static int getRequiredBufferSize(int capacity)
-
offer
public boolean offer(java.lang.Integer e)
-
offerInt
public boolean offerInt(int e)
-
poll
public java.lang.Integer poll()
-
pollInt
public int pollInt()
-
calcElementOffset
private long calcElementOffset(long currentHead)
-
peek
public java.lang.Integer peek()
-
peekInt
public int peekInt()
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<java.lang.Integer>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Integer>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<java.lang.Integer>- Overrides:
isEmptyin classjava.util.AbstractCollection<java.lang.Integer>
-
iterator
public java.util.Iterator<java.lang.Integer> iterator()
- Specified by:
iteratorin interfacejava.util.Collection<java.lang.Integer>- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Integer>- Specified by:
iteratorin classjava.util.AbstractCollection<java.lang.Integer>
-
getHeadPlain
private long getHeadPlain()
-
getHead
private long getHead()
-
setHead
private void setHead(long value)
-
getTailPlain
private long getTailPlain()
-
getTail
private long getTail()
-
setTail
private void setTail(long value)
-
getHeadCache
private long getHeadCache()
-
setHeadCache
private void setHeadCache(long value)
-
getTailCache
private long getTailCache()
-
setTailCache
private void setTailCache(long value)
-
-