Package io.netty.util
Interface ReferenceCounted
-
- All Known Subinterfaces:
AddressedEnvelope<M,A>,Attribute,BinaryMemcacheMessage,BinaryMemcacheRequest,BinaryMemcacheResponse,BulkStringRedisContent,ByteBufHolder,DnsMessage,DnsQuery,DnsRawRecord,DnsResponse,FileRegion,FileUpload,FullBinaryMemcacheRequest,FullBinaryMemcacheResponse,FullHttpMessage,FullHttpRequest,FullHttpResponse,FullMemcacheMessage,Http2DataFrame,Http2GoAwayFrame,Http2UnknownFrame,Http3DataFrame,Http3UnknownFrame,HttpContent,HttpData,InterfaceHttpData,LastBulkStringRedisContent,LastHttpContent,LastMemcacheContent,LastSmtpContent,LastStompContentSubframe,MemcacheContent,MemcacheMessage,QuicStreamFrame,SmtpContent,SpdyDataFrame,SpdyUnknownFrame,StompContentSubframe,StompFrame
- All Known Implementing Classes:
AbstractBinaryMemcacheMessage,AbstractByteBuf,AbstractDerivedByteBuf,AbstractDiskHttpData,AbstractDnsMessage,AbstractHttpData,AbstractMemcacheObject,AbstractMemoryHttpData,AbstractReferenceCounted,AbstractReferenceCountedByteBuf,ArrayRedisMessage,BinaryWebSocketFrame,ByteBuf,CloseWebSocketFrame,CompositeByteBuf,ContinuationWebSocketFrame,DatagramDnsQuery,DatagramDnsResponse,DatagramPacket,DefaultAddressedEnvelope,DefaultBinaryMemcacheRequest,DefaultBinaryMemcacheResponse,DefaultBulkStringRedisContent,DefaultByteBufHolder,DefaultDnsQuery,DefaultDnsRawRecord,DefaultDnsResponse,DefaultFileRegion,DefaultFullBinaryMemcacheRequest,DefaultFullBinaryMemcacheResponse,DefaultFullHttpRequest,DefaultFullHttpResponse,DefaultHttp2DataFrame,DefaultHttp2GoAwayFrame,DefaultHttp2UnknownFrame,DefaultHttp3DataFrame,DefaultHttp3UnknownFrame,DefaultHttpContent,DefaultLastBulkStringRedisContent,DefaultLastHttpContent,DefaultLastMemcacheContent,DefaultLastSmtpContent,DefaultLastStompContentSubframe,DefaultMemcacheContent,DefaultQuicStreamFrame,DefaultSmtpContent,DefaultSpdyDataFrame,DefaultSpdyUnknownFrame,DefaultStompContentSubframe,DefaultStompFrame,DiskAttribute,DiskFileUpload,DomainDatagramPacket,DuplicatedByteBuf,EmptyByteBuf,FullBulkStringRedisMessage,HAProxyMessage,HAProxySSLTLV,HAProxyTLV,HttpServerUpgradeHandler.UpgradeEvent,MemoryAttribute,MemoryFileUpload,MixedAttribute,MixedFileUpload,MqttPublishMessage,OpenSslClientContext,OpenSslContext,OpenSslEngine,OpenSslServerContext,PemPrivateKey,PemX509Certificate,PingWebSocketFrame,PongWebSocketFrame,ReadOnlyByteBuf,ReferenceCountedOpenSslClientContext,ReferenceCountedOpenSslContext,ReferenceCountedOpenSslEngine,ReferenceCountedOpenSslServerContext,SctpMessage,SegmentedDatagramPacket,SegmentedDatagramPacket,SlicedByteBuf,SwappedByteBuf,TextWebSocketFrame,UdtMessage,UnpooledDirectByteBuf,UnpooledHeapByteBuf,UnpooledUnsafeDirectByteBuf,UnpooledUnsafeHeapByteBuf,WebSocketFrame,WrappedByteBuf
public interface ReferenceCountedA reference-counted object that requires explicit deallocation.When a new
ReferenceCountedis 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
ReferenceCountedis 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 intrefCnt()Returns the reference count of this object.booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement)Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.ReferenceCountedretain()Increases the reference count by1.ReferenceCountedretain(int increment)Increases the reference count by the specifiedincrement.ReferenceCountedtouch()Records the current access location of this object for debugging purposes.ReferenceCountedtouch(java.lang.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(java.lang.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 by1and deallocates this object if the reference count reaches at0.- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
boolean release(int decrement)
Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
-