Package org.agrona.concurrent.status
Class UnsafeBufferPosition
java.lang.Object
org.agrona.concurrent.status.ReadablePosition
org.agrona.concurrent.status.Position
org.agrona.concurrent.status.UnsafeBufferPosition
- All Implemented Interfaces:
AutoCloseable
Reports a position by recording it in an
UnsafeBuffer.-
Constructor Summary
ConstructorsConstructorDescriptionUnsafeBufferPosition(UnsafeBuffer buffer, int counterId) Map a position over a buffer.UnsafeBufferPosition(UnsafeBuffer buffer, int counterId, CountersManager countersManager) Map a position over a buffer and this indicator owns the counter for reclamation. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longget()Get the current position of a component with plain memory semantics.longGet the current position of a component with acquire memory semantics.longGet the current position of a component with opaque memory semantics.longGet the current position of a component with volatile memory semantics.intid()Identifier for this position.booleanisClosed()Has this Position been closed?booleanproposeMax(long proposedValue) Set the position to a new proposedValue if greater than the current value with plain memory semantics.booleanproposeMaxOpaque(long proposedValue) Set the position to the new proposedValue if greater than the current value with opaque memory semantics.booleanproposeMaxOrdered(long proposedValue) Set the position to the new proposedValue if greater than the current value with release memory semantics.booleanproposeMaxRelease(long proposedValue) Set the position to the new proposedValue if greater than the current value with release memory semantics.voidset(long value) Sets the current position of the component plain memory semantics.voidsetOpaque(long value) Sets the current position of the component with opaque memory semantics.voidsetOrdered(long value) Sets the current position of the component with ordered memory semantics.voidsetRelease(long value) Sets the current position of the component with release memory semantics.voidsetVolatile(long value) Sets the current position of the component with volatile memory semantics.toString()
-
Constructor Details
-
UnsafeBufferPosition
Map a position over a buffer.- Parameters:
buffer- containing the counter.counterId- identifier of the counter.
-
UnsafeBufferPosition
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 Details
-
isClosed
public boolean isClosed()Has this Position been closed? -
id
public int id()Identifier for this position.- Specified by:
idin classReadablePosition- Returns:
- the identifier for this position.
-
getVolatile
public long getVolatile()Get the current position of a component with volatile memory semantics.- Specified by:
getVolatilein classReadablePosition- Returns:
- the current position of a component.
-
getAcquire
public long getAcquire()Get the current position of a component with acquire memory semantics.- Specified by:
getAcquirein classReadablePosition- Returns:
- the current position of a component.
-
getOpaque
public long getOpaque()Get the current position of a component with opaque memory semantics.- Specified by:
getOpaquein classReadablePosition- Returns:
- the current position of a component
-
get
public long get()Get the current position of a component with plain memory semantics.- Specified by:
getin classReadablePosition- 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:
setVolatilein classPosition- 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:
setOrderedin classPosition- 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:
setReleasein classPosition- 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. -
set
public void set(long value) Sets the current position of the component plain memory semantics. -
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:
proposeMaxin classPosition- 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:
proposeMaxOrderedin classPosition- 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:
proposeMaxReleasein classPosition- 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:
proposeMaxOpaquein classPosition- Parameters:
proposedValue- for the new max.- Returns:
- true if a new max as been set otherwise false.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classReadablePosition
-
toString
-