Package org.jctools.util
Class UnsafeRefArrayAccess
- java.lang.Object
-
- org.jctools.util.UnsafeRefArrayAccess
-
public final class UnsafeRefArrayAccess extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static longREF_ARRAY_BASEstatic intREF_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 longcalcCircularRefElementOffset(long index, long mask)Note: circular arrays are assumed a power of 2 in length and the `mask` is (length - 1).static longcalcRefElementOffset(long index)static <E> ElpRefElement(E[] buffer, long offset)A plain load (no ordering/fences) of an element from a given offset.static <E> ElvRefElement(E[] buffer, long offset)A volatile load of an element from a given offset.static <E> voidsoRefElement(E[] buffer, long offset, E e)An ordered store of an element to a given offsetstatic <E> voidspRefElement(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.
-
-