Package io.netty.buffer
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 int
private final Queue
<PoolThreadCache.MemoryRegionCache.Entry<T>> private static final ObjectPool
<PoolThreadCache.MemoryRegionCache.Entry> private final int
private final PoolArena.SizeClass
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
add
(PoolChunk<T> chunk, ByteBuffer nioBuffer, long handle, int normCapacity) Add to cache if not already full.final boolean
allocate
(PooledByteBuf<T> buf, int reqCapacity, PoolThreadCache threadCache) Allocate something out of the cache if possible and remove the entry from the cache.final int
free
(boolean finalizer) Clear out this cache and free up all previous cachedPoolChunk
s andhandle
s.private int
free
(int max, boolean finalizer) private void
freeEntry
(PoolThreadCache.MemoryRegionCache.Entry entry, boolean finalizer) protected abstract void
initBuf
(PoolChunk<T> chunk, ByteBuffer nioBuffer, long handle, PooledByteBuf<T> buf, int reqCapacity, PoolThreadCache threadCache) Init thePooledByteBuf
using the provided chunk and handle with the capacity restrictions.private static PoolThreadCache.MemoryRegionCache.Entry
newEntry
(PoolChunk<?> chunk, ByteBuffer nioBuffer, long handle, int normCapacity) final void
trim()
Free up cachedPoolChunk
s 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 thePooledByteBuf
using 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 cachedPoolChunk
s andhandle
s. -
free
private int free(int max, boolean finalizer) -
trim
public final void trim()Free up cachedPoolChunk
s if not allocated frequently enough. -
freeEntry
-
newEntry
private static PoolThreadCache.MemoryRegionCache.Entry newEntry(PoolChunk<?> chunk, ByteBuffer nioBuffer, long handle, int normCapacity)
-