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:
java.lang.AutoCloseable
public class UnsafeBufferPosition extends Position
Reports a position by recording it in anUnsafeBuffer
.
-
-
Field Summary
Fields Modifier and Type Field Description private long
addressOffset
private byte[]
byteArray
private java.nio.ByteBuffer
byteBuffer
private int
counterId
private CountersManager
countersManager
private boolean
isClosed
-
Constructor Summary
Constructors Constructor Description UnsafeBufferPosition(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
long
get()
Get the current position of a component without memory ordering semantics.long
getVolatile()
Get the current position of a component with volatile 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 without memory ordering semantics.boolean
proposeMaxOrdered(long proposedValue)
Set the position to the new proposedValue if greater than the current value with memory ordering semantics.void
set(long value)
Sets the current position of the component without memory ordering semantics.void
setOrdered(long value)
Sets the current position of the component with ordered memory semantics.void
setVolatile(long value)
Sets the current position of the component with volatile memory semantics.java.lang.String
toString()
-
-
-
Field Detail
-
isClosed
private boolean isClosed
-
counterId
private final int counterId
-
addressOffset
private final long addressOffset
-
byteArray
private final byte[] byteArray
-
countersManager
private final CountersManager countersManager
-
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?
-
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 without memory ordering semantics.
-
getVolatile
public long getVolatile()
Get the current position of a component with volatile semantics.- Specified by:
getVolatile
in classReadablePosition
- Returns:
- the current position of a component with volatile semantics.
-
set
public void set(long value)
Sets the current position of the component without memory ordering semantics.
-
setOrdered
public void setOrdered(long value)
Sets the current position of the component with ordered memory semantics.- Specified by:
setOrdered
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 without memory ordering 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 memory ordering semantics.- Specified by:
proposeMaxOrdered
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in classReadablePosition
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-