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
private abstract static class PoolThreadCache.MemoryRegionCache<T> extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
PoolThreadCache.MemoryRegionCache.Entry<T>
-
Field Summary
Fields Modifier and Type Field Description private int
allocations
private java.util.Queue<PoolThreadCache.MemoryRegionCache.Entry<T>>
queue
private static ObjectPool<PoolThreadCache.MemoryRegionCache.Entry>
RECYCLER
private int
size
private PoolArena.SizeClass
sizeClass
-
Constructor Summary
Constructors Constructor Description MemoryRegionCache(int size, PoolArena.SizeClass sizeClass)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
add(PoolChunk<T> chunk, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity)
Add to cache if not already full.boolean
allocate(PooledByteBuf<T> buf, int reqCapacity, PoolThreadCache threadCache)
Allocate something out of the cache if possible and remove the entry from the cache.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, java.nio.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, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity)
void
trim()
Free up cachedPoolChunk
s if not allocated frequently enough.
-
-
-
Field Detail
-
size
private final int size
-
queue
private final java.util.Queue<PoolThreadCache.MemoryRegionCache.Entry<T>> queue
-
sizeClass
private final PoolArena.SizeClass sizeClass
-
allocations
private int allocations
-
RECYCLER
private static final ObjectPool<PoolThreadCache.MemoryRegionCache.Entry> RECYCLER
-
-
Constructor Detail
-
MemoryRegionCache
MemoryRegionCache(int size, PoolArena.SizeClass sizeClass)
-
-
Method Detail
-
initBuf
protected abstract void initBuf(PoolChunk<T> chunk, java.nio.ByteBuffer nioBuffer, long handle, PooledByteBuf<T> buf, int reqCapacity, PoolThreadCache threadCache)
Init thePooledByteBuf
using the provided chunk and handle with the capacity restrictions.
-
add
public final boolean add(PoolChunk<T> chunk, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity)
Add to cache if not already full.
-
allocate
public 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.
-
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
private void freeEntry(PoolThreadCache.MemoryRegionCache.Entry entry, boolean finalizer)
-
newEntry
private static PoolThreadCache.MemoryRegionCache.Entry newEntry(PoolChunk<?> chunk, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity)
-
-