Class PoolThreadCache.MemoryRegionCache<T>
java.lang.Object
io.netty.buffer.PoolThreadCache.MemoryRegionCache<T>
- Direct Known Subclasses:
PoolThreadCache.NormalMemoryRegionCache, PoolThreadCache.SubPageMemoryRegionCache
- Enclosing class:
PoolThreadCache
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate final Queue<PoolThreadCache.MemoryRegionCache.Entry<T>> private static final ObjectPool<PoolThreadCache.MemoryRegionCache.Entry> private final intprivate final PoolArena.SizeClass -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanadd(PoolChunk<T> chunk, ByteBuffer nioBuffer, long handle, int normCapacity) Add to cache if not already full.final booleanallocate(PooledByteBuf<T> buf, int reqCapacity, PoolThreadCache threadCache) Allocate something out of the cache if possible and remove the entry from the cache.final intfree(boolean finalizer) Clear out this cache and free up all previous cachedPoolChunks andhandles.private intfree(int max, boolean finalizer) private voidfreeEntry(PoolThreadCache.MemoryRegionCache.Entry entry, boolean finalizer) protected abstract voidinitBuf(PoolChunk<T> chunk, ByteBuffer nioBuffer, long handle, PooledByteBuf<T> buf, int reqCapacity, PoolThreadCache threadCache) Init thePooledByteBufusing the provided chunk and handle with the capacity restrictions.private static PoolThreadCache.MemoryRegionCache.EntrynewEntry(PoolChunk<?> chunk, ByteBuffer nioBuffer, long handle, int normCapacity) final voidtrim()Free up cachedPoolChunks if not allocated frequently enough.
-
Field Details
-
size
private final int size -
queue
-
sizeClass
-
allocations
private int allocations -
RECYCLER
-
-
Constructor Details
-
MemoryRegionCache
MemoryRegionCache(int size, PoolArena.SizeClass sizeClass)
-
-
Method Details
-
initBuf
protected abstract void initBuf(PoolChunk<T> chunk, ByteBuffer nioBuffer, long handle, PooledByteBuf<T> buf, int reqCapacity, PoolThreadCache threadCache) Init thePooledByteBufusing the provided chunk and handle with the capacity restrictions. -
add
Add to cache if not already full. -
allocate
Allocate something out of the cache if possible and remove the entry from the cache. -
free
public final int free(boolean finalizer) Clear out this cache and free up all previous cachedPoolChunks andhandles. -
free
private int free(int max, boolean finalizer) -
trim
public final void trim()Free up cachedPoolChunks if not allocated frequently enough. -
freeEntry
-
newEntry
private static PoolThreadCache.MemoryRegionCache.Entry newEntry(PoolChunk<?> chunk, ByteBuffer nioBuffer, long handle, int normCapacity)
-