public abstract class AbstractReferenceCounted extends java.lang.Object implements ReferenceCounted
ReferenceCounted.| Modifier and Type | Field and Description |
|---|---|
private int |
refCnt |
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractReferenceCounted> |
refCntUpdater |
| Constructor and Description |
|---|
AbstractReferenceCounted() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
deallocate()
Called once
refCnt() is equals 0. |
int |
refCnt()
Returns the reference count of this object.
|
boolean |
release()
Decreases the reference count by
1 and deallocates this object if the reference count reaches at
0. |
boolean |
release(int decrement)
Decreases the reference count by the specified
decrement and deallocates this object if the reference
count reaches at 0. |
private boolean |
release0(int decrement) |
ReferenceCounted |
retain()
Increases the reference count by
1. |
ReferenceCounted |
retain(int increment)
Increases the reference count by the specified
increment. |
private ReferenceCounted |
retain0(int increment) |
protected void |
setRefCnt(int refCnt)
An unsafe operation intended for use by a subclass that sets the reference count of the buffer directly
|
ReferenceCounted |
touch()
Records the current access location of this object for debugging purposes.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waittouchprivate static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractReferenceCounted> refCntUpdater
private volatile int refCnt
public final int refCnt()
ReferenceCounted0, it means this object has been deallocated.refCnt in interface ReferenceCountedprotected final void setRefCnt(int refCnt)
public ReferenceCounted retain()
ReferenceCounted1.retain in interface ReferenceCountedpublic ReferenceCounted retain(int increment)
ReferenceCountedincrement.retain in interface ReferenceCountedprivate ReferenceCounted retain0(int increment)
public ReferenceCounted touch()
ReferenceCountedResourceLeakDetector. This method is a shortcut to touch(null).touch in interface ReferenceCountedpublic boolean release()
ReferenceCounted1 and deallocates this object if the reference count reaches at
0.release in interface ReferenceCountedtrue if and only if the reference count became 0 and this object has been deallocatedpublic boolean release(int decrement)
ReferenceCounteddecrement and deallocates this object if the reference
count reaches at 0.release in interface ReferenceCountedtrue if and only if the reference count became 0 and this object has been deallocatedprivate boolean release0(int decrement)
protected abstract void deallocate()
refCnt() is equals 0.