private abstract static class PoolThreadCache.MemoryRegionCache<T>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
PoolThreadCache.MemoryRegionCache.Entry<T> |
| Modifier and Type | Field and Description |
|---|---|
private int |
allocations |
private java.util.Queue<PoolThreadCache.MemoryRegionCache.Entry<T>> |
queue |
private static Recycler<PoolThreadCache.MemoryRegionCache.Entry> |
RECYCLER |
private int |
size |
private PoolArena.SizeClass |
sizeClass |
| Constructor and Description |
|---|
MemoryRegionCache(int size,
PoolArena.SizeClass sizeClass) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(PoolChunk<T> chunk,
long handle)
Add to cache if not already full.
|
boolean |
allocate(PooledByteBuf<T> buf,
int reqCapacity)
Allocate something out of the cache if possible and remove the entry from the cache.
|
int |
free()
Clear out this cache and free up all previous cached
PoolChunks and handles. |
private int |
free(int max) |
private void |
freeEntry(PoolThreadCache.MemoryRegionCache.Entry entry) |
protected abstract void |
initBuf(PoolChunk<T> chunk,
long handle,
PooledByteBuf<T> buf,
int reqCapacity)
Init the
PooledByteBuf using the provided chunk and handle with the capacity restrictions. |
private static PoolThreadCache.MemoryRegionCache.Entry |
newEntry(PoolChunk<?> chunk,
long handle) |
void |
trim()
Free up cached
PoolChunks if not allocated frequently enough. |
private final int size
private final java.util.Queue<PoolThreadCache.MemoryRegionCache.Entry<T>> queue
private final PoolArena.SizeClass sizeClass
private int allocations
private static final Recycler<PoolThreadCache.MemoryRegionCache.Entry> RECYCLER
MemoryRegionCache(int size,
PoolArena.SizeClass sizeClass)
protected abstract void initBuf(PoolChunk<T> chunk, long handle, PooledByteBuf<T> buf, int reqCapacity)
PooledByteBuf using the provided chunk and handle with the capacity restrictions.public final boolean allocate(PooledByteBuf<T> buf, int reqCapacity)
public final int free()
PoolChunks and handles.private int free(int max)
public final void trim()
PoolChunks if not allocated frequently enough.private void freeEntry(PoolThreadCache.MemoryRegionCache.Entry entry)
private static PoolThreadCache.MemoryRegionCache.Entry newEntry(PoolChunk<?> chunk, long handle)