Package io.netty.buffer
Class PoolSubpage<T>
- java.lang.Object
-
- io.netty.buffer.PoolSubpage<T>
-
- All Implemented Interfaces:
PoolSubpageMetric
final class PoolSubpage<T> extends java.lang.Object implements PoolSubpageMetric
-
-
Field Summary
Fields Modifier and Type Field Description private long[]bitmapprivate intbitmapLength(package private) PoolChunk<T>chunk(package private) booleandoNotDestroy(package private) intelemSizeprivate intmaxNumElemsprivate intmemoryMapIdx(package private) PoolSubpage<T>nextprivate intnextAvailprivate intnumAvailprivate intpageSize(package private) PoolSubpage<T>prevprivate intrunOffset
-
Constructor Summary
Constructors Constructor Description PoolSubpage(int pageSize)Special constructor that creates a linked list headPoolSubpage(PoolSubpage<T> head, PoolChunk<T> chunk, int memoryMapIdx, int runOffset, int pageSize, int elemSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddToPool(PoolSubpage<T> head)(package private) longallocate()Returns the bitmap index of the subpage allocation.(package private) voiddestroy()intelementSize()Return the size (in bytes) of the elements that will be allocated.private intfindNextAvail()private intfindNextAvail0(int i, long bits)(package private) booleanfree(PoolSubpage<T> head, int bitmapIdx)private intgetNextAvail()(package private) voidinit(PoolSubpage<T> head, int elemSize)intmaxNumElements()Return the number of maximal elements that can be allocated out of the sub-page.intnumAvailable()Return the number of available elements to be allocated.intpageSize()Return the size (in bytes) of this page.private voidremoveFromPool()private voidsetNextAvail(int bitmapIdx)private longtoHandle(int bitmapIdx)java.lang.StringtoString()
-
-
-
Field Detail
-
memoryMapIdx
private final int memoryMapIdx
-
runOffset
private final int runOffset
-
pageSize
private final int pageSize
-
bitmap
private final long[] bitmap
-
prev
PoolSubpage<T> prev
-
next
PoolSubpage<T> next
-
doNotDestroy
boolean doNotDestroy
-
elemSize
int elemSize
-
maxNumElems
private int maxNumElems
-
bitmapLength
private int bitmapLength
-
nextAvail
private int nextAvail
-
numAvail
private int numAvail
-
-
Constructor Detail
-
PoolSubpage
PoolSubpage(int pageSize)
Special constructor that creates a linked list head
-
PoolSubpage
PoolSubpage(PoolSubpage<T> head, PoolChunk<T> chunk, int memoryMapIdx, int runOffset, int pageSize, int elemSize)
-
-
Method Detail
-
init
void init(PoolSubpage<T> head, int elemSize)
-
allocate
long allocate()
Returns the bitmap index of the subpage allocation.
-
free
boolean free(PoolSubpage<T> head, int bitmapIdx)
- Returns:
trueif this subpage is in use.falseif this subpage is not used by its chunk and thus it's OK to be released.
-
addToPool
private void addToPool(PoolSubpage<T> head)
-
removeFromPool
private void removeFromPool()
-
setNextAvail
private void setNextAvail(int bitmapIdx)
-
getNextAvail
private int getNextAvail()
-
findNextAvail
private int findNextAvail()
-
findNextAvail0
private int findNextAvail0(int i, long bits)
-
toHandle
private long toHandle(int bitmapIdx)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
maxNumElements
public int maxNumElements()
Description copied from interface:PoolSubpageMetricReturn the number of maximal elements that can be allocated out of the sub-page.- Specified by:
maxNumElementsin interfacePoolSubpageMetric
-
numAvailable
public int numAvailable()
Description copied from interface:PoolSubpageMetricReturn the number of available elements to be allocated.- Specified by:
numAvailablein interfacePoolSubpageMetric
-
elementSize
public int elementSize()
Description copied from interface:PoolSubpageMetricReturn the size (in bytes) of the elements that will be allocated.- Specified by:
elementSizein interfacePoolSubpageMetric
-
pageSize
public int pageSize()
Description copied from interface:PoolSubpageMetricReturn the size (in bytes) of this page.- Specified by:
pageSizein interfacePoolSubpageMetric
-
destroy
void destroy()
-
-