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 long
arrayBase
private java.nio.ByteBuffer
buffy
private int
capacity
static byte
CONSUMER
private long
headAddress
private long
headCacheAddress
static int
INT_ELEMENT_SCALE
private int
mask
static byte
PRODUCER
private long
tailAddress
private long
tailCacheAddress
-
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 long
calcElementOffset(long currentHead)
private long
getHead()
private long
getHeadCache()
private long
getHeadPlain()
static int
getRequiredBufferSize(int capacity)
private long
getTail()
private long
getTailCache()
private long
getTailPlain()
boolean
isEmpty()
java.util.Iterator<java.lang.Integer>
iterator()
boolean
offer(java.lang.Integer e)
boolean
offerInt(int e)
java.lang.Integer
peek()
int
peekInt()
java.lang.Integer
poll()
int
pollInt()
private void
setHead(long value)
private void
setHeadCache(long value)
private void
setTail(long value)
private void
setTailCache(long value)
int
size()
-
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:
size
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
size
in classjava.util.AbstractCollection<java.lang.Integer>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Collection<java.lang.Integer>
- Overrides:
isEmpty
in classjava.util.AbstractCollection<java.lang.Integer>
-
iterator
public java.util.Iterator<java.lang.Integer> iterator()
- Specified by:
iterator
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Integer>
- Specified by:
iterator
in 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)
-
-