Package org.agrona.concurrent.status
Class AtomicLongPosition
java.lang.Object
org.agrona.concurrent.status.ReadablePosition
org.agrona.concurrent.status.Position
org.agrona.concurrent.status.AtomicLongPosition
- All Implemented Interfaces:
AutoCloseable
Position
that is backed by an AtomicLong
which is useful for tests.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.AtomicLongPosition
(int id) Create a position with a given id and zero as an initial value.AtomicLongPosition
(int id, long initialValue) Create a position with a given id and an initial value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
long
get()
Get the current position of a component with plain memory semantics.long
Get the current position of a component with acquire memory semantics.long
Get the current position of a component with opaque memory semantics.long
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.toString()
-
Field Details
-
isClosed
private boolean isClosed -
id
private final int id -
value
-
-
Constructor Details
-
AtomicLongPosition
public AtomicLongPosition()Default constructor. -
AtomicLongPosition
public AtomicLongPosition(int id) Create a position with a given id and zero as an initial value.- Parameters:
id
- to be assigned.
-
AtomicLongPosition
public AtomicLongPosition(int id, long initialValue) Create a position with a given id and an initial value.- Parameters:
id
- to be assigned.initialValue
- to be assigned.
-
-
Method Details
-
isClosed
public boolean isClosed()Has this Position been closed? -
id
public int id()Identifier for this position.- Specified by:
id
in classReadablePosition
- Returns:
- the identifier for this position.
-
get
public long get()Get the current position of a component with plain memory semantics.- Specified by:
get
in classReadablePosition
- Returns:
- the current position of a component
-
getVolatile
public long getVolatile()Get the current position of a component with volatile memory semantics.- Specified by:
getVolatile
in 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:
getAcquire
in 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:
getOpaque
in classReadablePosition
- Returns:
- the current position of a component
-
set
public void set(long value) Sets the current position of the component plain memory semantics. -
setOpaque
public void setOpaque(long value) Sets the current position of the component with opaque memory semantics. -
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 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:
setRelease
in classPosition
- Parameters:
value
- the current position of the component.
-
setVolatile
public void setVolatile(long value) Sets the current position of the component with volatile memory semantics.- Specified by:
setVolatile
in classPosition
- 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 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:
proposeMaxOrdered
in 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:
proposeMaxRelease
in 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:
proposeMaxOpaque
in classPosition
- 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 interfaceAutoCloseable
- Specified by:
close
in classReadablePosition
-
toString
-