public abstract class AbstractReference extends net.openhft.chronicle.core.io.AbstractCloseable implements Byteable, net.openhft.chronicle.core.io.Closeable
BytesStore
.
This class provides an abstraction for managing a reference to a BytesStore. It provides functionality to read and write data from/to the BytesStore, manage a reference count, and lock resources.
BytesStore
,
Byteable
,
Closeable
Modifier and Type | Field and Description |
---|---|
protected @Nullable BytesStore<?,?> |
bytes
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 ByteStore to which this object currently points.
|
void |
bytesStore(@NotNull BytesStore bytes,
long offset,
long length)
Sets the underlying BytesStore to work with, along 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 offset within the ByteStore to which this object currently points.
|
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.
|
assertCloseable, assertCloseablesClosed, clearUsedByThread, close, createdHere, disableCloseableTracing, disableThreadSafetyCheck, disableThreadSafetyCheck, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, resetUsedByThread, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, toString, unmonitor, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
@Nullable protected @Nullable BytesStore<?,?> bytes
protected long offset
protected AbstractReference()
public void bytesStore(@NotNull @NotNull BytesStore bytes, long offset, long length) throws IllegalStateException, IllegalArgumentException, BufferOverflowException
bytesStore
in interface Byteable
bytes
- the BytesStore to setoffset
- the offset to setlength
- the length to setIllegalStateException
- if the state is invalidIllegalArgumentException
- if the arguments are invalidBufferOverflowException
- if the provided buffer is too small@Nullable public @Nullable BytesStore bytesStore()
Byteable
bytesStore
in interface Byteable
public long offset()
Byteable
protected void acceptNewBytesStore(@NotNull @NotNull BytesStore bytes) throws IllegalStateException
bytes
- the new BytesStoreIllegalStateException
- if this reference has been closedprotected void performClose()
performClose
in class net.openhft.chronicle.core.io.AbstractCloseable
public long address() throws IllegalStateException, BufferUnderflowException
address
in interface Byteable
IllegalStateException
- if the state is invalidBufferUnderflowException
- if the buffer does not have enough contentpublic FileLock lock(boolean shared) throws IOException
lock
in interface Byteable
shared
- 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 Byteable
shared
- if true the lock will be shared, otherwise it will be exclusive.IOException
- if an I/O error occursCopyright © 2023. All rights reserved.