Package org.jctools.util
Class UnsafeLongArrayAccess
- java.lang.Object
-
- org.jctools.util.UnsafeLongArrayAccess
-
public final class UnsafeLongArrayAccess extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static long
LONG_ARRAY_BASE
static int
LONG_ELEMENT_SHIFT
-
Constructor Summary
Constructors Constructor Description UnsafeLongArrayAccess()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long[]
allocateLongArray(int capacity)
This makes for an easier time generating the atomic queues, and removes some warnings.static long
calcCircularLongElementOffset(long index, long mask)
Note: circular arrays are assumed a power of 2 in length and the `mask` is (length - 1).static long
calcLongElementOffset(long index)
static long
lpLongElement(long[] buffer, long offset)
A plain load (no ordering/fences) of an element from a given offset.static long
lvLongElement(long[] buffer, long offset)
A volatile load of an element from a given offset.static void
soLongElement(long[] buffer, long offset, long e)
An ordered store of an element to a given offsetstatic void
spLongElement(long[] buffer, long offset, long e)
A plain store (no ordering/fences) of an element to a given offset
-
-
-
Method Detail
-
spLongElement
public static void spLongElement(long[] buffer, long offset, long e)
A plain store (no ordering/fences) of an element to a given offset- Parameters:
buffer
- le bufferoffset
- computed viacalcLongElementOffset(long)
e
- an orderly kitty
-
soLongElement
public static void soLongElement(long[] buffer, long offset, long e)
An ordered store of an element to a given offset- Parameters:
buffer
- le bufferoffset
- computed viacalcCircularLongElementOffset(long, long)
e
- an orderly kitty
-
lpLongElement
public static long lpLongElement(long[] buffer, long offset)
A plain load (no ordering/fences) of an element from a given offset.- Parameters:
buffer
- le bufferoffset
- computed viacalcLongElementOffset(long)
- Returns:
- the element at the offset
-
lvLongElement
public static long lvLongElement(long[] buffer, long offset)
A volatile load of an element from a given offset.- Parameters:
buffer
- le bufferoffset
- computed viacalcCircularLongElementOffset(long, long)
- Returns:
- the element at the offset
-
calcLongElementOffset
public static long calcLongElementOffset(long index)
- Parameters:
index
- desirable element index- Returns:
- the offset in bytes within the array for a given index
-
calcCircularLongElementOffset
public static long calcCircularLongElementOffset(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
-
allocateLongArray
public static long[] allocateLongArray(int capacity)
This makes for an easier time generating the atomic queues, and removes some warnings.
-
-