public abstract class UnsafeCloseable extends AbstractCloseable
Unsafe.
Not thread-safe. The memory address is set via address(long) and the
clean-up is performed in performClose().| Modifier and Type | Field and Description |
|---|---|
protected long |
address |
protected sun.misc.Unsafe |
unsafe |
closedHere, DISABLE_DISCARD_WARNING, WARN_NSINIT, TMPDISABLE_SINGLE_THREADED_CHECK| Modifier | Constructor and Description |
|---|---|
protected |
UnsafeCloseable()
Disable the single-threaded check because these resources are typically
accessed from multiple threads.
|
| Modifier and Type | Method and Description |
|---|---|
long |
addAtomicLong(long delta)
Adds the specified value to the long value stored at the memory address and returns the updated value.
|
long |
addLong(long delta)
Adds the specified value to the long value stored at the memory address and returns the updated value.
|
protected void |
address(long address)
Assign the backing memory address.
|
boolean |
compareAndSwapLong(long expected,
long value)
Compares the value at the memory address with the expected value and, if they match, sets the value to a new value.
|
long |
getLong()
Gets the long value stored at the memory address.
|
long |
getVolatileLong()
Gets the volatile long value stored at the memory address.
|
long |
getVolatileLong(long closedLong)
Gets the volatile long value stored at the memory address, or a default value if the resource is closed.
|
protected void |
performClose()
Implement the clean-up logic.
|
void |
setLong(long value)
Sets the long value at the memory address.
|
void |
setOrderedLong(long value)
Sets the ordered long value at the memory address.
|
void |
setVolatileLong(long value)
Sets the volatile long value at the memory address.
|
assertCloseable, assertCloseablesClosed, close, createdHere, disableCloseableTracing, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, toString, unmonitor, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitreferenceName, temporarycloseQuietly, closeQuietlyunmonitorprotected UnsafeCloseable()
protected void address(long address)
protected void performClose()
throws IllegalStateException
AbstractCloseableclose() invokes this method exactly
once via AbstractCloseable.callPerformClose().performClose in class AbstractCloseableIllegalStateExceptionpublic long getLong()
throws ClosedIllegalStateException,
ThreadingIllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic void setLong(long value)
throws ClosedIllegalStateException,
ThreadingIllegalStateException
value - The long value to set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic long getVolatileLong()
throws ClosedIllegalStateException,
ThreadingIllegalStateException
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic void setVolatileLong(long value)
throws ClosedIllegalStateException,
ThreadingIllegalStateException
value - The volatile long value to set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic long getVolatileLong(long closedLong)
throws ClosedIllegalStateException
closedLong - The default value to return if the resource is closed.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic void setOrderedLong(long value)
throws ClosedIllegalStateException,
ThreadingIllegalStateException
value - The ordered long value to set.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic long addLong(long delta)
throws ClosedIllegalStateException,
ThreadingIllegalStateException
delta - The value to add.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic long addAtomicLong(long delta)
throws ClosedIllegalStateException,
ThreadingIllegalStateException
addLong(long).delta - The value to add.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe waypublic boolean compareAndSwapLong(long expected,
long value)
throws ClosedIllegalStateException,
ThreadingIllegalStateException
expected - The expected value.value - The new value to set.true if the swap was successful, false otherwise.ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If used in a non thread safe wayCopyright © 2026 Chronicle Software Ltd. All rights reserved.