public abstract class AbstractReference extends net.openhft.chronicle.core.io.AbstractCloseable implements Byteable, net.openhft.chronicle.core.io.Closeable
BytesStore.
acceptNewBytesStore(BytesStore) reserves the store and
performClose() releases it. Subclasses must call
throwExceptionIfClosed...() before mutating state.
unmonitor() propagates to the wrapped store.
BytesStore,
Byteable,
Closeable| Modifier and Type | Field and Description |
|---|---|
protected @Nullable BytesStore |
bytesStore
BytesStore associated with this reference
|
protected long |
offset
Offset within the BytesStore for this reference
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractReference()
Constructor initializes the reference assuming thread safety.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
acceptNewBytesStore(@NotNull BytesStore<?,?> bytes)
Updates the BytesStore for this reference, releasing any previous BytesStore
|
long |
address()
Retrieves the memory address for reading.
|
@Nullable BytesStore<?,?> |
bytesStore()
Returns the
BytesStore that backs this reference, or null if none is set. |
void |
bytesStore(@NotNull BytesStore bytes,
long offset,
long length)
Sets the underlying
BytesStore together with the offset and length. |
FileLock |
lock(boolean shared)
Attempts to lock a region in the file in either shared or exclusive mode.
|
long |
offset()
Returns the byte offset relative to the start of the associated store.
|
protected void |
performClose()
Closes this reference, releasing any associated BytesStore
|
FileLock |
tryLock(boolean shared)
Attempts to lock a region in the file in either shared or exclusive mode,
but does not block waiting for the lock.
|
void |
unmonitor() |
assertCloseable, assertCloseablesClosed, close, createdHere, disableCloseableTracing, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, toString, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, closeQuietly, closeQuietly@Nullable protected @Nullable BytesStore bytesStore
protected long offset
protected AbstractReference()
public void bytesStore(@NotNull
@NotNull BytesStore bytes,
long offset,
long length)
throws IllegalStateException,
IllegalArgumentException,
BufferOverflowException
BytesStore together with the offset and length.bytesStore in interface Byteablebytes - the BytesStore providing the backing memoryoffset - the non-negative offset within the storelength - the number of bytes this reference spansIllegalArgumentException - if length does not match Byteable.maxSize()BufferOverflowException - if the region exceeds the store capacitynet.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@Nullable public @Nullable BytesStore<?,?> bytesStore()
BytesStore that backs this reference, or null if none is set.bytesStore in interface ByteableBytesStore or null if unmappedpublic long offset()
offset in interface ByteableBytesStoreprotected void acceptNewBytesStore(@NotNull
@NotNull BytesStore<?,?> bytes)
throws IllegalStateException
bytes - the new BytesStorenet.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 wayIllegalStateExceptionprotected void performClose()
performClose in class net.openhft.chronicle.core.io.AbstractCloseablepublic long address()
throws IllegalStateException,
BufferUnderflowException
address in interface ByteableBufferUnderflowException - If the buffer does not have enough contentnet.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 FileLock lock(boolean shared) throws IOException
lock in interface Byteableshared - if true the lock will be shared, otherwise it will be exclusive.IOException - If an I/O error occurspublic FileLock tryLock(boolean shared) throws IOException
tryLock in interface Byteableshared - if true the lock will be shared, otherwise it will be exclusive.IOException - If an I/O error occurspublic void unmonitor()
unmonitor in interface net.openhft.chronicle.core.io.Monitorableunmonitor in class net.openhft.chronicle.core.io.AbstractCloseableCopyright © 2026 Chronicle Software Ltd. All rights reserved.