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.
BinaryLongReference
LONG_NOT_COMPLETE
bytesStore, 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, setVolatileValue
acceptNewBytesStore, address, bytesStore, lock, offset, performClose, tryLock, unmonitor
assertCloseable, assertCloseablesClosed, close, createdHere, disableCloseableTracing, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, unmonitor, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAtomicValue, addValue, close, compareAndSwapValue, getValue, getVolatileValue, getVolatileValue, isClosed, setMaxValue, setMinValue, setOrderedValue, setValue, setVolatileValue
address, bytesStore, bytesStore, lock, offset, tryLock
public long maxSize()
maxSize
in interface Byteable
maxSize
in class BinaryLongReference
@NotNull public @NotNull String toString()
toString
in class BinaryLongReference
public long getValue2() throws IllegalStateException
getValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
net.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 wayIllegalStateException
public void setValue2(long value) throws IllegalStateException
setValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
value
- 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 wayIllegalStateException
public long getVolatileValue2() throws IllegalStateException
getVolatileValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
IllegalStateException
- If closedpublic void setVolatileValue2(long value) throws IllegalStateException
setVolatileValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
value
- 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 wayIllegalStateException
public void setOrderedValue2(long value) throws IllegalStateException
setOrderedValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
value
- 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 wayIllegalStateException
public long addValue2(long delta) throws IllegalStateException
addValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
delta
- 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 wayIllegalStateException
public long addAtomicValue2(long delta) throws IllegalStateException
addAtomicValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
delta
- 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 wayIllegalStateException
public boolean compareAndSwapValue2(long expected, long value) throws IllegalStateException
compareAndSwapValue2
in interface net.openhft.chronicle.core.values.TwoLongValue
expected
- 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 wayIllegalStateException
Copyright © 2024. All rights reserved.