public class BinaryIntReference extends AbstractReference implements net.openhft.chronicle.core.values.IntValue
BytesStore.
Example usage:
try (BinaryIntReference ref = new BinaryIntReference()) {
ref.bytesStore(store, offset, ref.maxSize());
ref.setValue(10);
}
All volatile methods provide a full happens-before edge. Ordered
methods use lazy set semantics. maxSize() always returns Integer.BYTES.
Negative values are valid; INT_NOT_COMPLETE is only a
replay sentinel.
BytesStore,
IntValue| Modifier and Type | Field and Description |
|---|---|
static int |
INT_NOT_COMPLETE
Sentinel value used when an integer operation fails to complete normally.
|
bytesStore, offset| Constructor and Description |
|---|
BinaryIntReference() |
| Modifier and Type | Method and Description |
|---|---|
int |
addAtomicValue(int delta)
Adds a delta to the current 32-bit integer value atomically and returns the result.
|
int |
addValue(int delta)
Adds a delta to the current 32-bit integer value and returns the result.
|
void |
bytesStore(@NotNull BytesStore bytes,
long offset,
long length)
Sets the BytesStore which this reference points to.
|
boolean |
compareAndSwapValue(int expected,
int value)
Atomically sets the 32-bit integer value to the given updated value if the current value is
equal to the expected value.
|
int |
getValue()
Performs a plain read of the value from the backing store.
|
int |
getVolatileValue()
Retrieves the 32-bit integer value using volatile memory semantics.
|
long |
maxSize()
Returns the maximum size of this reference in bytes (4 bytes for a 32-bit integer).
|
void |
setOrderedValue(int value)
Sets the 32-bit integer value using ordered or lazy set memory semantics.
|
void |
setValue(int value)
Writes the value to the backing store using plain semantics.
|
@NotNull String |
toString()
Returns a string representation of this BinaryIntReference.
|
acceptNewBytesStore, 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, waitpublic static final int INT_NOT_COMPLETE
public void bytesStore(@NotNull
@NotNull BytesStore bytes,
long offset,
long length)
throws IllegalStateException,
IllegalArgumentException,
BufferOverflowException
bytesStore in interface ByteablebytesStore in class AbstractReferencebytes - the BytesStoreoffset - the offset within the BytesStorelength - the length of the valueIllegalArgumentException - If the length is not equal to maxSizeBufferOverflowException - If the offset is too largenet.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 maxSize()
@NotNull public @NotNull String toString()
toString in class net.openhft.chronicle.core.io.AbstractCloseablepublic int getValue()
throws IllegalStateException,
BufferUnderflowException
getValue in interface net.openhft.chronicle.core.values.IntValueBufferUnderflowException - if the offset is invalidnet.openhft.chronicle.core.io.ClosedIllegalStateException - if the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if accessed by multiple threads unsafelyIllegalStateExceptionpublic void setValue(int value)
throws IllegalStateException,
BufferOverflowException
setValue in interface net.openhft.chronicle.core.values.IntValuevalue - the value to storeBufferOverflowException - if the offset is invalidnet.openhft.chronicle.core.io.ClosedIllegalStateException - if the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if accessed by multiple threads unsafelyIllegalStateExceptionpublic int getVolatileValue()
throws IllegalStateException,
BufferUnderflowException
getVolatileValue in interface net.openhft.chronicle.core.values.IntValueBufferUnderflowException - If the offset is too largenet.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 setOrderedValue(int value)
throws IllegalStateException,
BufferOverflowException
setOrderedValue in interface net.openhft.chronicle.core.values.IntValuevalue - the 32-bit integer value to setBufferOverflowException - If the offset is too largenet.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 int addValue(int delta)
throws IllegalStateException,
BufferUnderflowException
addValue in interface net.openhft.chronicle.core.values.IntValuedelta - the value to addBufferUnderflowException - If the offset is too largenet.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 way
This atomic fetch-and-add forms a happens-before edge with subsequent reads of the value.
IllegalStateExceptionpublic int addAtomicValue(int delta)
throws IllegalStateException,
BufferUnderflowException
addAtomicValue in interface net.openhft.chronicle.core.values.IntValuedelta - the value to addBufferUnderflowException - If the offset is too largenet.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 compareAndSwapValue(int expected,
int value)
throws IllegalStateException,
BufferOverflowException
compareAndSwapValue in interface net.openhft.chronicle.core.values.IntValueexpected - the expected 32-bit integer valuevalue - the new 32-bit integer valueBufferOverflowException - If the offset is too largenet.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 way
A successful swap establishes a happens-before relation with subsequent reads of the value.
IllegalStateExceptionCopyright © 2026 Chronicle Software Ltd. All rights reserved.