public interface TwoLongValue extends LongValue
long values, providing mechanisms for getting, setting, and
manipulating them with various memory ordering effects.
This interface extends LongValue, which provides the base
functionality for a single long value. This interface adds support for a second long value.
Concrete implementations are responsible for managing the storage and retrieval mechanisms of these long
values.
Notable methods of this interface include:
getValue2() - Retrieves the second long value.setValue2(long) - Sets the second long value.getVolatileValue2() - Retrieves the second long value with volatile semantics.setVolatileValue2(long) - Sets the second long value with volatile semantics.addValue2(long) - Atomically adds the given amount to the second long value.compareAndSwapValue2(long, long) - Atomically sets the second long value if it is equal to the expected value.Additionally, the interface provides default implementations for setting the second value to the maximum or minimum of the current value and a specified value, and for atomically setting and retrieving both values.
Implementations can also include additional behaviors or optimizations not specified in this interface.
Note: The LongValue.getValue() and LongValue.setValue(long) methods inherited from LongValue are applicable
to the first long value. Implementations must ensure that all methods are thread-safe and that changes
to the values are correctly synchronized across threads.
LongValue,
BooleanValue,
ByteValue,
CharValue,
DoubleValue,
FloatValue,
IntValue,
LongValue,
ShortValue,
StringValue,
LongArrayValues,
IntArrayValues| Modifier and Type | Method and Description |
|---|---|
long |
addAtomicValue2(long delta)
Atomically adds the specified value to the second long value.
|
long |
addValue2(long delta)
Adds the specified value to the second long value and returns the result.
|
boolean |
compareAndSwapValue2(long expected,
long value)
Atomically compares the current second long value with the expected value,
and if they match, updates the second value to the specified new value.
|
long |
getValue2()
Retrieves the second long value.
|
long |
getVolatileValue2()
Retrieves the second long value using volatile semantics.
|
void |
setOrderedValue2(long value)
Sets the second long value using ordered semantics.
|
void |
setValue2(long value2)
Sets the second long value.
|
void |
setVolatileValue2(long value)
Sets the second long value using volatile semantics.
|
addAtomicValue, addValue, close, compareAndSwapValue, getValue, getVolatileValue, getVolatileValue, isClosed, setMaxValue, setMinValue, setOrderedValue, setValue, setVolatileValuecloseQuietly, closeQuietlyisClosinglong getValue2()
throws IllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid setValue2(long value2)
throws IllegalStateException
value2 - The value to set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionlong getVolatileValue2()
throws IllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid setVolatileValue2(long value)
throws IllegalStateException
value - The value to set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid setOrderedValue2(long value)
throws IllegalStateException
value - The value to set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionlong addValue2(long delta)
throws IllegalStateException
delta - The value to add.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionlong addAtomicValue2(long delta)
throws IllegalStateException
delta - The value to add.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionboolean compareAndSwapValue2(long expected,
long value)
throws IllegalStateException
expected - The expected value.value - The new value.true if the swap was successful, otherwise false.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionCopyright © 2024. All rights reserved.