Class UnsafeBufferPosition

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class UnsafeBufferPosition
    extends Position
    Reports a position by recording it in an UnsafeBuffer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      long get()
      Get the current position of a component with plain memory semantics.
      long getAcquire()
      Get the current position of a component with acquire memory semantics.
      long getOpaque()
      Get the current position of a component with opaque memory semantics.
      long getVolatile()
      Get the current position of a component with volatile memory semantics.
      int id()
      Identifier for this position.
      boolean isClosed()
      Has this Position been closed?
      boolean proposeMax​(long proposedValue)
      Set the position to a new proposedValue if greater than the current value with plain memory semantics.
      boolean proposeMaxOpaque​(long proposedValue)
      Set the position to the new proposedValue if greater than the current value with opaque memory semantics.
      boolean proposeMaxOrdered​(long proposedValue)
      Set the position to the new proposedValue if greater than the current value with release memory semantics.
      boolean proposeMaxRelease​(long proposedValue)
      Set the position to the new proposedValue if greater than the current value with release memory semantics.
      void set​(long value)
      Sets the current position of the component plain memory semantics.
      void setOpaque​(long value)
      Sets the current position of the component with opaque memory semantics.
      void setOrdered​(long value)
      Sets the current position of the component with ordered memory semantics.
      void setRelease​(long value)
      Sets the current position of the component with release memory semantics.
      void setVolatile​(long value)
      Sets the current position of the component with volatile memory semantics.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

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

      • isClosed

        private boolean isClosed
      • counterId

        private final int counterId
      • addressOffset

        private final long addressOffset
      • byteArray

        private final byte[] byteArray
      • byteBuffer

        private final java.nio.ByteBuffer byteBuffer
    • Constructor Detail

      • UnsafeBufferPosition

        public UnsafeBufferPosition​(UnsafeBuffer buffer,
                                    int counterId)
        Map a position over a buffer.
        Parameters:
        buffer - containing the counter.
        counterId - identifier of the counter.
      • UnsafeBufferPosition

        public UnsafeBufferPosition​(UnsafeBuffer buffer,
                                    int counterId,
                                    CountersManager countersManager)
        Map a position over a buffer and this indicator owns the counter for reclamation.
        Parameters:
        buffer - containing the counter.
        counterId - identifier of the counter.
        countersManager - to be used for freeing the counter when this is closed.
    • Method Detail

      • isClosed

        public boolean isClosed()
        Has this Position been closed?
        Specified by:
        isClosed in class Position
        Returns:
        true if this position has already been closed.
      • id

        public int id()
        Identifier for this position.
        Specified by:
        id in class ReadablePosition
        Returns:
        the identifier for this position.
      • getVolatile

        public long getVolatile()
        Get the current position of a component with volatile memory semantics.
        Specified by:
        getVolatile in class ReadablePosition
        Returns:
        the current position of a component.
      • getAcquire

        public long getAcquire()
        Get the current position of a component with acquire memory semantics.
        Specified by:
        getAcquire in class ReadablePosition
        Returns:
        the current position of a component.
      • getOpaque

        public long getOpaque()
        Get the current position of a component with opaque memory semantics.
        Specified by:
        getOpaque in class ReadablePosition
        Returns:
        the current position of a component
      • get

        public long get()
        Get the current position of a component with plain memory semantics.
        Specified by:
        get in class ReadablePosition
        Returns:
        the current position of a component
      • setVolatile

        public void setVolatile​(long value)
        Sets the current position of the component with volatile memory semantics.
        Specified by:
        setVolatile in class Position
        Parameters:
        value - the current position of the component.
      • setOrdered

        public void setOrdered​(long value)
        Sets the current position of the component with ordered memory semantics.

        This method is identical to Position.setRelease(long) and that method should be used instead.

        Specified by:
        setOrdered in class Position
        Parameters:
        value - the current position of the component.
      • setRelease

        public void setRelease​(long value)
        Sets the current position of the component with release memory semantics.
        Specified by:
        setRelease in class Position
        Parameters:
        value - the current position of the component.
      • setOpaque

        public void setOpaque​(long value)
        Sets the current position of the component with opaque memory semantics.
        Specified by:
        setOpaque in class Position
        Parameters:
        value - the current position of the component.
      • set

        public void set​(long value)
        Sets the current position of the component plain memory semantics.
        Specified by:
        set in class Position
        Parameters:
        value - the current position of the component.
      • proposeMax

        public boolean proposeMax​(long proposedValue)
        Set the position to a new proposedValue if greater than the current value with plain memory semantics.
        Specified by:
        proposeMax in class Position
        Parameters:
        proposedValue - for the new max.
        Returns:
        true if a new max as been set otherwise false.
      • proposeMaxOrdered

        public boolean proposeMaxOrdered​(long proposedValue)
        Set the position to the new proposedValue if greater than the current value with release memory semantics.

        This method is identical to Position.proposeMaxRelease(long) and that method should be preferred instead.

        Specified by:
        proposeMaxOrdered in class Position
        Parameters:
        proposedValue - for the new max.
        Returns:
        true if a new max as been set otherwise false.
      • proposeMaxRelease

        public boolean proposeMaxRelease​(long proposedValue)
        Set the position to the new proposedValue if greater than the current value with release memory semantics.
        Specified by:
        proposeMaxRelease in class Position
        Parameters:
        proposedValue - for the new max.
        Returns:
        true if a new max as been set otherwise false.
      • proposeMaxOpaque

        public boolean proposeMaxOpaque​(long proposedValue)
        Set the position to the new proposedValue if greater than the current value with opaque memory semantics.
        Specified by:
        proposeMaxOpaque in class Position
        Parameters:
        proposedValue - for the new max.
        Returns:
        true if a new max as been set otherwise false.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in class ReadablePosition
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object