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 |
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 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.
|
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 in interface Byteablebytes - the BytesStore to setoffset - the offset to setlength - the length to setIllegalArgumentException - If the arguments are invalidBufferOverflowException - If the provided buffer is too smallnet.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()
ByteablebytesStore in interface Byteablepublic long offset()
Byteableprotected 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 © 2024. All rights reserved.