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
,HttpContent
,HttpData
,InterfaceHttpData
,LastBulkStringRedisContent
,LastHttpContent
,LastMemcacheContent
,LastSmtpContent
,LastStompContentSubframe
,MemcacheContent
,MemcacheMessage
,OpenSslKeyMaterial
,PemEncoded
,SmtpContent
,SpdyDataFrame
,StompContentSubframe
,StompFrame
- All Known Implementing Classes:
AbstractBinaryMemcacheMessage
,AbstractByteBuf
,AbstractDerivedByteBuf
,AbstractDiskHttpData
,AbstractDnsMessage
,AbstractHttpData
,AbstractMemcacheObject
,AbstractMemoryHttpData
,AbstractMixedHttpData
,AbstractPooledDerivedByteBuf
,AbstractPooledDerivedByteBuf.PooledNonRetainedDuplicateByteBuf
,AbstractPooledDerivedByteBuf.PooledNonRetainedSlicedByteBuf
,AbstractReferenceCounted
,AbstractReferenceCountedByteBuf
,AbstractUnpooledSlicedByteBuf
,AbstractUnsafeSwappedByteBuf
,AdaptivePoolingAllocator.AdaptiveByteBuf
,AdaptivePoolingAllocator.Chunk
,AdvancedLeakAwareByteBuf
,AdvancedLeakAwareCompositeByteBuf
,ArrayRedisMessage
,BinaryWebSocketFrame
,ByteBuf
,ByteBufUtil.ThreadLocalDirectByteBuf
,ByteBufUtil.ThreadLocalUnsafeDirectByteBuf
,CloseWebSocketFrame
,ComposedLastHttpContent
,CompositeByteBuf
,ContinuationWebSocketFrame
,DatagramDnsQuery
,DatagramDnsResponse
,DatagramPacket
,DefaultAddressedEnvelope
,DefaultBinaryMemcacheRequest
,DefaultBinaryMemcacheResponse
,DefaultBulkStringRedisContent
,DefaultByteBufHolder
,DefaultDnsQuery
,DefaultDnsRawRecord
,DefaultDnsResponse
,DefaultFileRegion
,DefaultFullBinaryMemcacheRequest
,DefaultFullBinaryMemcacheResponse
,DefaultFullHttpRequest
,DefaultFullHttpResponse
,DefaultHttp2DataFrame
,DefaultHttp2GoAwayFrame
,DefaultHttp2UnknownFrame
,DefaultHttpContent
,DefaultLastBulkStringRedisContent
,DefaultLastHttpContent
,DefaultLastMemcacheContent
,DefaultLastSmtpContent
,DefaultLastStompContentSubframe
,DefaultMemcacheContent
,DefaultOpenSslKeyMaterial
,DefaultSmtpContent
,DefaultSpdyDataFrame
,DefaultStompContentSubframe
,DefaultStompFrame
,DiskAttribute
,DiskFileUpload
,DnsQueryContext.AddressedEnvelopeAdapter
,DomainDatagramPacket
,DuplicatedByteBuf
,EmptyByteBuf
,FixedCompositeByteBuf
,FixedCompositeByteBuf.Component
,FullBulkStringRedisMessage
,HAProxyMessage
,HAProxySSLTLV
,HAProxyTLV
,HttpObjectAggregator.AggregatedFullHttpMessage
,HttpObjectAggregator.AggregatedFullHttpRequest
,HttpObjectAggregator.AggregatedFullHttpResponse
,HttpPostRequestEncoder.WrappedFullHttpRequest
,HttpServerUpgradeHandler.UpgradeEvent
,InternalAttribute
,MemoryAttribute
,MemoryFileUpload
,MixedAttribute
,MixedFileUpload
,MqttPublishMessage
,OpenSslClientContext
,OpenSslContext
,OpenSslEngine
,OpenSslPrivateKey
,OpenSslPrivateKey.OpenSslPrivateKeyMaterial
,OpenSslServerContext
,PemPrivateKey
,PemValue
,PemX509Certificate
,PingWebSocketFrame
,PongWebSocketFrame
,PooledByteBuf
,PooledDirectByteBuf
,PooledDuplicatedByteBuf
,PooledHeapByteBuf
,PooledSlicedByteBuf
,PooledUnsafeDirectByteBuf
,PooledUnsafeHeapByteBuf
,ReadOnlyByteBuf
,ReadOnlyByteBufferBuf
,ReadOnlyByteBufferBuf.ReadOnlyDuplicatedByteBuf
,ReadOnlyByteBufferBuf.ReadOnlySlicedByteBuf
,ReadOnlyUnsafeDirectByteBuf
,ReferenceCountedOpenSslClientContext
,ReferenceCountedOpenSslContext
,ReferenceCountedOpenSslEngine
,ReferenceCountedOpenSslServerContext
,ReplayingDecoderByteBuf
,SctpMessage
,SegmentedDatagramPacket
,SegmentedDatagramPacket
,SimpleLeakAwareByteBuf
,SimpleLeakAwareCompositeByteBuf
,SlicedByteBuf
,SwappedByteBuf
,TextWebSocketFrame
,UnpooledByteBufAllocator.InstrumentedUnpooledDirectByteBuf
,UnpooledByteBufAllocator.InstrumentedUnpooledHeapByteBuf
,UnpooledByteBufAllocator.InstrumentedUnpooledUnsafeDirectByteBuf
,UnpooledByteBufAllocator.InstrumentedUnpooledUnsafeHeapByteBuf
,UnpooledByteBufAllocator.InstrumentedUnpooledUnsafeNoCleanerDirectByteBuf
,UnpooledDirectByteBuf
,UnpooledDuplicatedByteBuf
,UnpooledHeapByteBuf
,UnpooledSlicedByteBuf
,UnpooledUnsafeDirectByteBuf
,UnpooledUnsafeHeapByteBuf
,UnpooledUnsafeNoCleanerDirectByteBuf
,UnreleasableByteBuf
,UnsafeDirectSwappedByteBuf
,UnsafeHeapSwappedByteBuf
,WebSocketFrame
,WrappedByteBuf
,WrappedCompositeByteBuf
,WrappedUnpooledUnsafeDirectByteBuf
public interface ReferenceCounted
A reference-counted object that requires explicit deallocation.
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.
-
Method Summary
Modifier and TypeMethodDescriptionint
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
.retain()
Increases the reference count by1
.retain
(int increment) Increases the reference count by the specifiedincrement
.touch()
Records the current access location of this object for debugging purposes.Records the current access location of this object with an additional arbitrary information for debugging purposes.
-
Method Details
-
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
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
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
-