-
- All Known Subinterfaces:
DnsMessage
,DnsQuery
,DnsResponse
,FileRegion
- All Known Implementing Classes:
AbstractDnsMessage
,AbstractReferenceCounted
,DatagramDnsQuery
,DatagramDnsResponse
,DefaultDnsQuery
,DefaultDnsResponse
,DefaultFileRegion
,OpenSslContext
,OpenSslEngine
,ReferenceCountedOpenSslClientContext
,ReferenceCountedOpenSslContext
,ReferenceCountedOpenSslEngine
,ReferenceCountedOpenSslServerContext
public interface ReferenceCounted
A reference-counted object that requires explicit deallocation.When a new
ReferenceCounted
is instantiated, it starts with the reference count of1
.retain()
increases the reference count, andrelease()
decreases the reference count. If the reference count is decreased to0
, 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 implementReferenceCounted
, the contained objects will also be released viarelease()
when the container's reference count becomes 0.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
refCnt()
Returns the reference count of this object.boolean
release()
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.boolean
release(int decrement)
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.ReferenceCounted
retain()
Increases the reference count by1
.ReferenceCounted
retain(int increment)
Increases the reference count by the specifiedincrement
.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.
-
-
-
Method Detail
-
refCnt
int refCnt()
Returns the reference count of this object. If0
, it means this object has been deallocated.
-
retain
ReferenceCounted retain()
Increases the reference count by1
.
-
retain
ReferenceCounted retain(int increment)
Increases the reference count by the specifiedincrement
.
-
touch
ReferenceCounted touch()
Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
. This method is a shortcut totouch(null)
.
-
touch
ReferenceCounted touch(Object hint)
Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
.
-
release
boolean release()
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
release
boolean release(int decrement)
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
-