public interface ReferenceCounted
When a new ReferenceCounted
is instantiated, it starts with the reference count of 1
.
retain()
increases the reference count, and release()
decreases the reference count.
If the reference count is decreased to 0
, the object will be deallocated explicitly, and accessing
the deallocated object will usually result in an access violation.
If an object that implements ReferenceCounted
is a container of other objects that implement
ReferenceCounted
, the contained objects will also be released via release()
when the container's
reference count becomes 0.
Modifier and Type | Method and Description |
---|---|
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 . |
ReferenceCounted |
retain()
Increases the reference count by
1 . |
ReferenceCounted |
retain(int increment)
Increases the reference count by the specified
increment . |
ReferenceCounted |
touch()
Records the current access location of this object for debugging purposes.
|
ReferenceCounted |
touch(Object hint)
Records the current access location of this object with an additional arbitrary information for debugging
purposes.
|
int refCnt()
0
, it means this object has been deallocated.ReferenceCounted retain()
1
.ReferenceCounted retain(int increment)
increment
.ReferenceCounted touch()
ResourceLeakDetector
. This method is a shortcut to touch(null)
.ReferenceCounted touch(Object hint)
ResourceLeakDetector
.boolean release()
1
and deallocates this object if the reference count reaches at
0
.true
if and only if the reference count became 0
and this object has been deallocatedboolean release(int decrement)
decrement
and deallocates this object if the reference
count reaches at 0
.true
if and only if the reference count became 0
and this object has been deallocatedCopyright © 2008–2017 The Netty Project. All rights reserved.