public class UncheckedLongReference extends net.openhft.chronicle.core.io.UnsafeCloseable implements LongReference, net.openhft.chronicle.core.io.ReferenceOwner
BytesStore without performing bounds checking.
This class is optimized for high performance in scenarios involving off-heap memory or memory-mapped files where bounds checks could impair performance.
This class is thread-safe provided that external synchronization is applied. It uses different implementations based on the JVM's debug status:
in debug mode, it uses BinaryLongReference for safety checks; otherwise, it uses UncheckedLongReference for better performance.
LongReference,
ReferenceOwner,
UnsafeCloseable,
BytesStore,
BinaryLongReference| Constructor and Description |
|---|
UncheckedLongReference() |
| Modifier and Type | Method and Description |
|---|---|
long |
addAtomicValue(long delta) |
long |
addValue(long delta) |
@NotNull BytesStore<?,?> |
bytesStore()
Returns the ByteStore to which this object currently points.
|
void |
bytesStore(@NotNull BytesStore bytes,
long offset,
long length)
Associates this
UncheckedLongReference with a BytesStore, specifying where the long value is stored and its length. |
boolean |
compareAndSwapValue(long expected,
long value) |
static @NotNull LongReference |
create(@NotNull BytesStore<?,?> bytesStore,
long offset,
int size)
Factory method to create a
UncheckedLongReference or BinaryLongReference based on the JVM's debug status. |
long |
getValue() |
long |
getVolatileValue() |
long |
getVolatileValue(long closedValue) |
long |
maxSize()
Returns the maximum size in bytes that this reference can point to.
|
long |
offset()
Returns the offset within the ByteStore to which this object currently points.
|
protected void |
performClose() |
void |
setOrderedValue(long value) |
void |
setValue(long value) |
void |
setVolatileValue(long value) |
@NotNull String |
toString() |
addAtomicLong, addLong, address, compareAndSwapLong, getLong, getVolatileLong, getVolatileLong, setLong, setOrderedLong, setVolatileLongassertCloseable, assertCloseablesClosed, close, createdHere, disableCloseableTracing, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, unmonitor, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, isClosed, setMaxValue, setMinValue@NotNull public static @NotNull LongReference create(@NotNull @NotNull BytesStore<?,?> bytesStore, long offset, int size) throws IllegalArgumentException, BufferOverflowException, BufferUnderflowException, IllegalStateException
UncheckedLongReference or BinaryLongReference based on the JVM's debug status.
This method initializes the reference with a specific BytesStore, offset, and size.bytesStore - The BytesStore used to store the long value.offset - The offset within the BytesStore where the long value starts.size - The size in bytes of the long value (expected to be 8 for a long).LongReference instance appropriate for the JVM debug status.IllegalArgumentException - If the provided size does not match the expected size of a long.BufferOverflowException - If the offset and size exceed the bounds of the BytesStore.BufferUnderflowException - If the offset is negative or not within the bounds of the BytesStore.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the BytesStore has already been closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this method is called from multiple threads without proper synchronization.IllegalStateExceptionpublic void bytesStore(@NotNull
@NotNull BytesStore bytes,
long offset,
long length)
throws IllegalStateException,
IllegalArgumentException,
BufferUnderflowException
UncheckedLongReference with a BytesStore, specifying where the long value is stored and its length.bytesStore in interface Byteablebytes - the BytesStore containing the long value.offset - the offset within the BytesStore where the long value starts.length - the length in bytes of the long value (expected to be 8).IllegalArgumentException - If the specified length does not match the expected size of a long.BufferUnderflowException - If the specified length and offset are out of the bounds of the BytesStore.net.openhft.chronicle.core.io.ClosedIllegalStateException - If this reference or the BytesStore has been closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this method is accessed by multiple threads without proper synchronization.IllegalStateException@NotNull public @NotNull BytesStore<?,?> bytesStore()
ByteablebytesStore in interface Byteablepublic long offset()
Byteablepublic long maxSize()
Byteable@NotNull public @NotNull String toString()
toString in class net.openhft.chronicle.core.io.AbstractCloseablepublic long getValue()
throws IllegalStateException
getValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionpublic void setValue(long value)
throws IllegalStateException
setValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionpublic long getVolatileValue()
throws IllegalStateException
getVolatileValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionpublic void setVolatileValue(long value)
throws IllegalStateException
setVolatileValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionpublic long getVolatileValue(long closedValue)
getVolatileValue in interface net.openhft.chronicle.core.values.LongValuepublic void setOrderedValue(long value)
throws IllegalStateException
setOrderedValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionpublic long addValue(long delta)
throws IllegalStateException
addValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionpublic long addAtomicValue(long delta)
throws IllegalStateException
addAtomicValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionpublic boolean compareAndSwapValue(long expected,
long value)
throws IllegalStateException
compareAndSwapValue in interface net.openhft.chronicle.core.values.LongValueIllegalStateExceptionprotected void performClose()
throws IllegalStateException
performClose in class net.openhft.chronicle.core.io.UnsafeCloseableIllegalStateExceptionCopyright © 2024. All rights reserved.