public abstract class UnsafeCloseable extends AbstractCloseable
Unsafe class for low-level memory operations.
Provides methods for manipulating long values stored at a specific memory address.| 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()
Constructs a new UnsafeCloseable instance.
|
| 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)
Sets the memory address for this resource.
|
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()
Contains the actual logic for closing the resource.
|
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)
address - The memory address.protected void performClose()
throws IllegalStateException
AbstractCloseable
Note: This method is called exactly once through 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 © 2024. All rights reserved.