| Modifier and Type | Field and Description |
|---|---|
(package private) static java.util.HashSet<java.lang.String> |
CALLERS |
private Task |
disposer |
private static int |
MAX_TRACES |
private java.util.concurrent.atomic.AtomicInteger |
retained |
private static boolean |
TRACE |
private java.util.ArrayList<java.lang.String> |
traces |
| Constructor and Description |
|---|
BaseRetained() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertRetained()
Subclasses can use this method to validate that the object has not yet been released.
|
protected void |
dispose()
This method will be called once the release retained reaches zero.
|
Task |
getDisposer() |
void |
release()
Decrement the reference count of this object.
|
protected void |
release(int n)
Decrements the reference count by n.
|
void |
retain()
Increment the reference count of this object.
|
int |
retained() |
void |
setDisposer(java.lang.Runnable disposer)
Adds a disposer runnable that is executed once the object is disposed.
|
void |
setDisposer(Task disposer)
Adds a disposer runnable that is executed once the object is disposed.
|
private static java.lang.String |
squash(java.lang.StackTraceElement[] st) |
private void |
trace(java.lang.String action,
int counter) |
private static final int MAX_TRACES
private static final boolean TRACE
private final java.util.concurrent.atomic.AtomicInteger retained
private volatile Task disposer
private final java.util.ArrayList<java.lang.String> traces
static java.util.HashSet<java.lang.String> CALLERS
public final void setDisposer(java.lang.Runnable disposer)
Adds a disposer runnable that is executed once the object is disposed.
A dispatch object's disposer runnable will be invoked on the object's target queue once the object's retain counter reaches zero. This disposer may be used by the application to release any resources associated with the object.
disposer - public final void setDisposer(Task disposer)
Adds a disposer runnable that is executed once the object is disposed.
A dispatch object's disposer runnable will be invoked on the object's target queue once the object's retain counter reaches zero. This disposer may be used by the application to release any resources associated with the object.
disposer - public final Task getDisposer()
public final void retain()
public final void release()
Decrement the reference count of this object.
An object is asynchronously disposed once all references are released. Using a disposed object will cause undefined errors. The system does not guarantee that a given client is the last or only reference to a given object.
protected final void release(int n)
Decrements the reference count by n.
An object is asynchronously disposed once all references are released. Using a disposed object will cause undefined errors. The system does not guarantee that a given client is the last or only reference to a given object.
n - protected final void assertRetained()
java.lang.IllegalStateException - if the object has been released.public final int retained()
protected void dispose()
This method will be called once the release retained reaches zero. It causes the set disposer runnabled to be executed if not null.
Subclasses should override if they want to implement a custom disposing action in addition to the actions performed by the disposer object.private final void trace(java.lang.String action,
int counter)
private static java.lang.String squash(java.lang.StackTraceElement[] st)