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.
LongValue
,
BooleanValue
,
ByteValue
,
CharValue
,
DoubleValue
,
FloatValue
,
IntValue
,
LongValue
,
ShortValue
,
StringValue
,
LongArrayValues
,
IntArrayValues
,
UnsetLongValue
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.
|
default void |
getValues(long[] values)
Deprecated.
|
long |
getVolatileValue2()
Retrieves the second long value using volatile semantics.
|
default void |
setMaxValue2(long value)
Deprecated.
|
default void |
setMinValue2(long value)
Deprecated.
|
void |
setOrderedValue2(long value)
Sets the second long value using ordered semantics.
|
void |
setValue2(long value2)
Sets the second long value.
|
default void |
setValues(long value1,
long value2)
Deprecated.
|
void |
setVolatileValue2(long value)
Sets the second long value using volatile semantics.
|
addAtomicValue, addValue, close, compareAndSwapValue, getValue, getVolatileValue, getVolatileValue, isClosed, setMaxValue, setMinValue, setOrderedValue, setValue, setVolatileValue
closeQuietly, closeQuietly
isClosing
long getValue2() throws IllegalStateException
ClosedIllegalStateException
- If the resource has been released or closed.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
void 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 wayIllegalStateException
long getVolatileValue2() throws IllegalStateException
ClosedIllegalStateException
- If the resource has been released or closed.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
void 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 wayIllegalStateException
void 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 wayIllegalStateException
long 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 wayIllegalStateException
long 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 wayIllegalStateException
boolean 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 wayIllegalStateException
@Deprecated default void setMaxValue2(long value) throws IllegalStateException
value
- The value to compare.ClosedIllegalStateException
- If the resource has been released or closed.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
@Deprecated default void setMinValue2(long value) throws IllegalStateException
value
- The value to compare.ClosedIllegalStateException
- If the resource has been released or closed.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
@Deprecated default void setValues(long value1, long value2) throws IllegalStateException
value1
- The first value to set.value2
- The second value to set.ClosedIllegalStateException
- If the resource has been released or closed.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
@Deprecated default void getValues(long[] values) throws IllegalStateException
values
- An array where the values will be stored. The first value is stored at index 0,
and the second value is stored at index 1.ClosedIllegalStateException
- If the resource has been released or closed.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
Copyright © 2023. All rights reserved.