Package org.jctools.util
Class UnsafeRefArrayAccess
- java.lang.Object
-
- org.jctools.util.UnsafeRefArrayAccess
-
public final class UnsafeRefArrayAccess extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static long
REF_ARRAY_BASE
static int
REF_ELEMENT_SHIFT
-
Constructor Summary
Constructors Constructor Description UnsafeRefArrayAccess()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> E[]
allocateRefArray(int capacity)
This makes for an easier time generating the atomic queues, and removes some warnings.static long
calcCircularRefElementOffset(long index, long mask)
Note: circular arrays are assumed a power of 2 in length and the `mask` is (length - 1).static long
calcRefElementOffset(long index)
static <E> E
lpRefElement(E[] buffer, long offset)
A plain load (no ordering/fences) of an element from a given offset.static <E> E
lvRefElement(E[] buffer, long offset)
A volatile load of an element from a given offset.static <E> void
soRefElement(E[] buffer, long offset, E e)
An ordered store of an element to a given offsetstatic <E> void
spRefElement(E[] buffer, long offset, E e)
A plain store (no ordering/fences) of an element to a given offset
-
-
-
Method Detail
-
spRefElement
public static <E> void spRefElement(E[] buffer, long offset, E e)
A plain store (no ordering/fences) of an element to a given offset- Parameters:
buffer
- this.bufferoffset
- computed viacalcRefElementOffset(long)
e
- an orderly kitty
-
soRefElement
public static <E> void soRefElement(E[] buffer, long offset, E e)
An ordered store of an element to a given offset- Parameters:
buffer
- this.bufferoffset
- computed viacalcCircularRefElementOffset(long, long)
e
- an orderly kitty
-
lpRefElement
public static <E> E lpRefElement(E[] buffer, long offset)
A plain load (no ordering/fences) of an element from a given offset.- Parameters:
buffer
- this.bufferoffset
- computed viacalcRefElementOffset(long)
- Returns:
- the element at the offset
-
lvRefElement
public static <E> E lvRefElement(E[] buffer, long offset)
A volatile load of an element from a given offset.- Parameters:
buffer
- this.bufferoffset
- computed viacalcRefElementOffset(long)
- Returns:
- the element at the offset
-
calcRefElementOffset
public static long calcRefElementOffset(long index)
- Parameters:
index
- desirable element index- Returns:
- the offset in bytes within the array for a given index
-
calcCircularRefElementOffset
public static long calcCircularRefElementOffset(long index, long mask)
Note: circular arrays are assumed a power of 2 in length and the `mask` is (length - 1).- Parameters:
index
- desirable element indexmask
- (length - 1)- Returns:
- the offset in bytes within the circular array for a given index
-
allocateRefArray
public static <E> E[] allocateRefArray(int capacity)
This makes for an easier time generating the atomic queues, and removes some warnings.
-
-