public interface Sequence
extends java.util.function.LongSupplier
Concurrent sequence class used for tracking the progress of the ring buffer and event processors. Support a number of concurrent operations including CAS and order writes.
Also attempts to be more efficient with regards to false sharing by adding padding around the volatile field.
Modifier and Type | Field and Description |
---|---|
static long |
INITIAL_VALUE |
Modifier and Type | Method and Description |
---|---|
long |
addAndGet(long increment)
Atomically add the supplied value.
|
boolean |
compareAndSet(long expectedValue,
long newValue)
Perform a compare and set operation on the sequence.
|
long |
getAsLong()
Perform a volatile read of this sequence's value.
|
long |
incrementAndGet()
Atomically increment the sequence by one.
|
void |
set(long value)
Perform an ordered write of this sequence.
|
void |
setVolatile(long value)
Performs a volatile write of this sequence.
|
static final long INITIAL_VALUE
long getAsLong()
getAsLong
in interface java.util.function.LongSupplier
void set(long value)
value
- The new value for the sequence.void setVolatile(long value)
value
- The new value for the sequence.boolean compareAndSet(long expectedValue, long newValue)
expectedValue
- The expected current value.newValue
- The value to update to.long incrementAndGet()
long addAndGet(long increment)
increment
- The value to add to the sequence.