public interface LongValue extends Closeable
This interface offers various methods for getting and setting the long value, including atomic operations like compare-and-swap and mechanisms to set values with volatile semantics.
Implementations of this interface should ensure thread-safety for concurrent modifications.
BooleanValue,
ByteValue,
CharValue,
DoubleValue,
FloatValue,
IntValue,
LongValue,
ShortValue,
StringValue,
LongArrayValues,
IntArrayValues| Modifier and Type | Method and Description |
|---|---|
default long |
addAtomicValue(long delta)
Atomically adds the specified delta to the current long value.
|
long |
addValue(long delta)
Adds the specified delta to the current long value.
|
default void |
close()
Closes the LongValue instance and releases any resources associated with it.
|
boolean |
compareAndSwapValue(long expected,
long value)
Atomically sets the value to the given updated value if the current value is equal to the expected value.
|
long |
getValue()
Retrieves the current long value.
|
default long |
getVolatileValue()
Retrieves the current long value with volatile semantics.
|
default long |
getVolatileValue(long closedValue)
Retrieves the current long value with volatile semantics, or returns the given
closedValue if the underlying resource is not available.
|
default boolean |
isClosed()
Checks if the LongValue instance is closed.
|
default void |
setMaxValue(long value)
Atomically sets the long value to the given value if it is greater than the current value.
|
default void |
setMinValue(long value)
Atomically sets the long value to the given value if it is less than the current value.
|
default void |
setOrderedValue(long value)
Sets the long value with ordered or lazy set semantics.
|
void |
setValue(long value)
Sets the long value.
|
default void |
setVolatileValue(long value)
Sets the long value with volatile semantics.
|
closeQuietly, closeQuietlyisClosinglong getValue()
throws IllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionvoid setValue(long value)
throws IllegalStateException
value - the new long value.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault long getVolatileValue()
throws IllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault void setVolatileValue(long value)
throws IllegalStateException
value - the new long value.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault long getVolatileValue(long closedValue)
throws IllegalStateException
closedValue - the value to return if the underlying resource is not available.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault void setOrderedValue(long value)
throws IllegalStateException
value - the new long value.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionlong addValue(long delta)
throws IllegalStateException
delta - the value to be added.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault long addAtomicValue(long delta)
throws IllegalStateException
delta - the value to be added.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionboolean compareAndSwapValue(long expected,
long value)
throws IllegalStateException
expected - the expected value.value - the new value.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault void setMaxValue(long value)
throws IllegalStateException
value - the value to be set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault void setMinValue(long value)
throws IllegalStateException
value - the value to be set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault boolean isClosed()
isClosed in interface QueryCloseabledefault void close()
close in interface AutoCloseableclose in interface CloseableAbstractCloseable.performClose()Copyright © 2024. All rights reserved.