Package io.netty.buffer
Class AdaptivePoolingAllocator.Chunk
- java.lang.Object
-
- io.netty.buffer.AdaptivePoolingAllocator.Chunk
-
- All Implemented Interfaces:
ReferenceCounted
- Direct Known Subclasses:
AdaptivePoolingAllocator.BuddyChunk,AdaptivePoolingAllocator.SizeClassedChunk
- Enclosing class:
- AdaptivePoolingAllocator
private static class AdaptivePoolingAllocator.Chunk extends java.lang.Object implements ReferenceCounted
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AdaptivePoolingAllocator.Chunk>AIF_UPDATERprotected intallocatedBytesprivate AdaptivePoolingAllocatorallocatorprivate intcapacityprotected AbstractByteBufdelegateprotected AdaptivePoolingAllocator.Magazinemagazineprivate intrefCntprivate static longREFCNT_FIELD_OFFSETprivate static ReferenceCountUpdater<AdaptivePoolingAllocator.Chunk>updater
-
Constructor Summary
Constructors Constructor Description Chunk()Chunk(AbstractByteBuf delegate, AdaptivePoolingAllocator.Magazine magazine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidattachToMagazine(AdaptivePoolingAllocator.Magazine magazine)intcapacity()(package private) AdaptivePoolingAllocator.MagazinecurrentMagazine()protected voiddeallocate()(package private) voiddetachFromMagazine()booleanhasUnprocessedFreelistEntries()(package private) voidmarkToDeallocate()voidprocessFreelistEntries()booleanreadInitInto(AdaptivePoolingAllocator.AdaptiveByteBuf buf, int size, int startingCapacity, int maxCapacity)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.(package private) voidreleaseFromMagazine()Called when a magazine is done using this chunk, probably because it was emptied.(package private) voidreleaseSegment(int ignoredSegmentId, int size)Called when a ByteBuf is done using its allocation in this chunk.intremainingCapacity()AdaptivePoolingAllocator.Chunkretain()Increases the reference count by1.AdaptivePoolingAllocator.Chunkretain(int increment)Increases the reference count by the specifiedincrement.AdaptivePoolingAllocator.Chunktouch()Records the current access location of this object for debugging purposes.AdaptivePoolingAllocator.Chunktouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.
-
-
-
Field Detail
-
REFCNT_FIELD_OFFSET
private static final long REFCNT_FIELD_OFFSET
-
AIF_UPDATER
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AdaptivePoolingAllocator.Chunk> AIF_UPDATER
-
delegate
protected final AbstractByteBuf delegate
-
magazine
protected AdaptivePoolingAllocator.Magazine magazine
-
allocator
private final AdaptivePoolingAllocator allocator
-
capacity
private final int capacity
-
allocatedBytes
protected int allocatedBytes
-
updater
private static final ReferenceCountUpdater<AdaptivePoolingAllocator.Chunk> updater
-
refCnt
private volatile int refCnt
-
-
Constructor Detail
-
Chunk
Chunk()
-
Chunk
Chunk(AbstractByteBuf delegate, AdaptivePoolingAllocator.Magazine magazine)
-
-
Method Detail
-
currentMagazine
AdaptivePoolingAllocator.Magazine currentMagazine()
-
detachFromMagazine
void detachFromMagazine()
-
attachToMagazine
void attachToMagazine(AdaptivePoolingAllocator.Magazine magazine)
-
touch
public AdaptivePoolingAllocator.Chunk touch(java.lang.Object hint)
Description copied from interface:ReferenceCountedRecords 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.- Specified by:
touchin interfaceReferenceCounted
-
refCnt
public int refCnt()
Description copied from interface:ReferenceCountedReturns the reference count of this object. If0, it means this object has been deallocated.- Specified by:
refCntin interfaceReferenceCounted
-
retain
public AdaptivePoolingAllocator.Chunk retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceReferenceCounted
-
retain
public AdaptivePoolingAllocator.Chunk retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceReferenceCounted
-
touch
public AdaptivePoolingAllocator.Chunk touch()
Description copied from interface:ReferenceCountedRecords 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).- Specified by:
touchin interfaceReferenceCounted
-
release
public boolean release()
Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public boolean release(int decrement)
Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
releaseFromMagazine
void releaseFromMagazine()
Called when a magazine is done using this chunk, probably because it was emptied.
-
releaseSegment
void releaseSegment(int ignoredSegmentId, int size)Called when a ByteBuf is done using its allocation in this chunk.
-
markToDeallocate
void markToDeallocate()
-
deallocate
protected void deallocate()
-
readInitInto
public boolean readInitInto(AdaptivePoolingAllocator.AdaptiveByteBuf buf, int size, int startingCapacity, int maxCapacity)
-
remainingCapacity
public int remainingCapacity()
-
hasUnprocessedFreelistEntries
public boolean hasUnprocessedFreelistEntries()
-
processFreelistEntries
public void processFreelistEntries()
-
capacity
public int capacity()
-
-