public class BinaryTwoLongReference extends BinaryLongReference implements TwoLongReference
This class extends BinaryLongReference and allows access to two 64-bit long values in a binary form,
which are contiguous in memory.
Example usage:
BytesStore bytesStore = BytesStore.nativeStoreWithFixedCapacity(16); // 16 bytes for two long values. BinaryTwoLongReference ref = new BinaryTwoLongReference(); ref.bytesStore(bytesStore, 0, ref.maxSize()); ref.setValue(1234567890L); // set the first long value ref.setValue2(9876543210L); // set the second long value
Note: This class is not thread-safe. External synchronization may be necessary if instances are shared between threads.
BinaryLongReferenceLONG_NOT_COMPLETEbytesStore, offset| Constructor and Description |
|---|
BinaryTwoLongReference() |
| Modifier and Type | Method and Description |
|---|---|
long |
addAtomicValue2(long delta)
Atomically adds a delta to the second 64-bit long value and returns the result.
|
long |
addValue2(long delta)
Adds a delta to the second 64-bit long value and returns the result.
|
boolean |
compareAndSwapValue2(long expected,
long value)
Atomically sets the second 64-bit long value to the given updated value if the current value is
equal to the expected value.
|
long |
getValue2()
Gets the second long value from the BinaryTwoLongReference.
|
long |
getVolatileValue2()
Retrieves the second 64-bit long value using volatile memory semantics.
|
long |
maxSize()
Returns the maximum size of this reference in bytes (16 bytes for two 64-bit longs).
|
void |
setOrderedValue2(long value)
Sets the second 64-bit long value using ordered or lazy set memory semantics.
|
void |
setValue2(long value)
Sets the second 64-bit long value in the BytesStore.
|
void |
setVolatileValue2(long value)
Sets the second 64-bit long value using volatile memory semantics.
|
@NotNull String |
toString()
Returns a string representation of this BinaryTwoLongReference.
|
addAtomicValue, addValue, bytesStore, compareAndSwapValue, getValue, getVolatileValue, setOrderedValue, setValue, setVolatileValueacceptNewBytesStore, address, bytesStore, lock, offset, performClose, tryLock, unmonitorassertCloseable, assertCloseablesClosed, close, createdHere, disableCloseableTracing, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddAtomicValue, addValue, close, compareAndSwapValue, getValue, getVolatileValue, getVolatileValue, isClosed, setMaxValue, setMinValue, setOrderedValue, setValue, setVolatileValueaddress, bytesStore, bytesStore, lock, offset, tryLockpublic long maxSize()
maxSize in interface ByteablemaxSize in class BinaryLongReference@NotNull public @NotNull String toString()
toString in class BinaryLongReferencepublic long getValue2()
throws IllegalStateException
getValue2 in interface net.openhft.chronicle.core.values.TwoLongValuenet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void setValue2(long value)
throws IllegalStateException
setValue2 in interface net.openhft.chronicle.core.values.TwoLongValuevalue - the second 64-bit long value to setnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic long getVolatileValue2()
throws IllegalStateException
getVolatileValue2 in interface net.openhft.chronicle.core.values.TwoLongValueIllegalStateException - If closedpublic void setVolatileValue2(long value)
throws IllegalStateException
setVolatileValue2 in interface net.openhft.chronicle.core.values.TwoLongValuevalue - the second 64-bit long value to setnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void setOrderedValue2(long value)
throws IllegalStateException
setOrderedValue2 in interface net.openhft.chronicle.core.values.TwoLongValuevalue - the second 64-bit long value to setnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic long addValue2(long delta)
throws IllegalStateException
addValue2 in interface net.openhft.chronicle.core.values.TwoLongValuedelta - the value to addnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic long addAtomicValue2(long delta)
throws IllegalStateException
addAtomicValue2 in interface net.openhft.chronicle.core.values.TwoLongValuedelta - the value to addnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic boolean compareAndSwapValue2(long expected,
long value)
throws IllegalStateException
compareAndSwapValue2 in interface net.openhft.chronicle.core.values.TwoLongValueexpected - the expected second 64-bit long valuevalue - the new second 64-bit long valuenet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionCopyright © 2024. All rights reserved.