Class UnsafeRefArrayAccess


  • public final class UnsafeRefArrayAccess
    extends java.lang.Object
    • 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 offset
      static <E> void spRefElement​(E[] buffer, long offset, E e)
      A plain store (no ordering/fences) of an element to a given offset
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • REF_ARRAY_BASE

        public static final long REF_ARRAY_BASE
      • REF_ELEMENT_SHIFT

        public static final int REF_ELEMENT_SHIFT
    • Constructor Detail

      • UnsafeRefArrayAccess

        public UnsafeRefArrayAccess()
    • 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.buffer
        offset - computed via calcRefElementOffset(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.buffer
        offset - computed via calcCircularRefElementOffset(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.buffer
        offset - computed via calcRefElementOffset(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.buffer
        offset - computed via calcRefElementOffset(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 index
        mask - (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.