Class UnsafeRefArrayAccess
java.lang.Object
org.jctools.util.UnsafeRefArrayAccess
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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
-
Field Details
-
REF_ARRAY_BASE
public static final long REF_ARRAY_BASE -
REF_ELEMENT_SHIFT
public static final int REF_ELEMENT_SHIFT
-
-
Constructor Details
-
UnsafeRefArrayAccess
public UnsafeRefArrayAccess()
-
-
Method Details
-
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.
-