Package io.netty.buffer
Class AdaptivePoolingAllocator.BuddyChunk
- java.lang.Object
-
- io.netty.buffer.AdaptivePoolingAllocator.Chunk
-
- io.netty.buffer.AdaptivePoolingAllocator.BuddyChunk
-
- All Implemented Interfaces:
IntConsumer,ReferenceCounted
- Enclosing class:
- AdaptivePoolingAllocator
private static final class AdaptivePoolingAllocator.BuddyChunk extends AdaptivePoolingAllocator.Chunk implements IntConsumer
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]buddiesprivate MpscIntQueuefreeListprivate intfreeListCapacityprivate static byteHAS_CLAIMED_CHILDRENprivate static byteIS_CLAIMEDprivate static intMIN_BUDDY_SIZEprivate static intPACK_OFFSET_MASKprivate static intPACK_SIZE_SHIFTprivate static byteSHIFT_MASK-
Fields inherited from class io.netty.buffer.AdaptivePoolingAllocator.Chunk
allocatedBytes, delegate, magazine
-
-
Constructor Summary
Constructors Constructor Description BuddyChunk(AbstractByteBuf delegate, AdaptivePoolingAllocator.Magazine magazine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(int packed)Consume anint.private intchooseFirstFreeBuddy(int index, int size, int currOffset)Claim a suitable buddy and return its start offset into the delegate chunk, or return -1 if nothing claimed.booleanhasUnprocessedFreelistEntries()voidprocessFreelistEntries()booleanreadInitInto(AdaptivePoolingAllocator.AdaptiveByteBuf buf, int size, int startingCapacity, int maxCapacity)(package private) voidreleaseSegment(int startingIndex, int size)Called when a ByteBuf is done using its allocation in this chunk.intremainingCapacity()java.lang.StringtoString()private booleanunreserveMatchingBuddy(int index, int size, int offset, int currOffset)Un-reserve the matching buddy and return whether there are any other child or sibling reservations.-
Methods inherited from class io.netty.buffer.AdaptivePoolingAllocator.Chunk
attachToMagazine, capacity, currentMagazine, deallocate, detachFromMagazine, markToDeallocate, refCnt, release, release, releaseFromMagazine, retain, retain, touch, touch
-
-
-
-
Field Detail
-
MIN_BUDDY_SIZE
private static final int MIN_BUDDY_SIZE
- See Also:
- Constant Field Values
-
IS_CLAIMED
private static final byte IS_CLAIMED
- See Also:
- Constant Field Values
-
HAS_CLAIMED_CHILDREN
private static final byte HAS_CLAIMED_CHILDREN
- See Also:
- Constant Field Values
-
SHIFT_MASK
private static final byte SHIFT_MASK
- See Also:
- Constant Field Values
-
PACK_OFFSET_MASK
private static final int PACK_OFFSET_MASK
- See Also:
- Constant Field Values
-
PACK_SIZE_SHIFT
private static final int PACK_SIZE_SHIFT
-
freeList
private final MpscIntQueue freeList
-
buddies
private final byte[] buddies
-
freeListCapacity
private final int freeListCapacity
-
-
Constructor Detail
-
BuddyChunk
BuddyChunk(AbstractByteBuf delegate, AdaptivePoolingAllocator.Magazine magazine)
-
-
Method Detail
-
readInitInto
public boolean readInitInto(AdaptivePoolingAllocator.AdaptiveByteBuf buf, int size, int startingCapacity, int maxCapacity)
- Overrides:
readInitIntoin classAdaptivePoolingAllocator.Chunk
-
accept
public void accept(int packed)
Description copied from interface:IntConsumerConsume anint.- Specified by:
acceptin interfaceIntConsumer
-
releaseSegment
void releaseSegment(int startingIndex, int size)Description copied from class:AdaptivePoolingAllocator.ChunkCalled when a ByteBuf is done using its allocation in this chunk.- Overrides:
releaseSegmentin classAdaptivePoolingAllocator.Chunk
-
remainingCapacity
public int remainingCapacity()
- Overrides:
remainingCapacityin classAdaptivePoolingAllocator.Chunk
-
hasUnprocessedFreelistEntries
public boolean hasUnprocessedFreelistEntries()
- Overrides:
hasUnprocessedFreelistEntriesin classAdaptivePoolingAllocator.Chunk
-
processFreelistEntries
public void processFreelistEntries()
- Overrides:
processFreelistEntriesin classAdaptivePoolingAllocator.Chunk
-
chooseFirstFreeBuddy
private int chooseFirstFreeBuddy(int index, int size, int currOffset)Claim a suitable buddy and return its start offset into the delegate chunk, or return -1 if nothing claimed.
-
unreserveMatchingBuddy
private boolean unreserveMatchingBuddy(int index, int size, int offset, int currOffset)Un-reserve the matching buddy and return whether there are any other child or sibling reservations.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-