Package io.netty.util
Class Recycler<T>
- java.lang.Object
-
- io.netty.util.Recycler<T>
-
- Type Parameters:
T
- the type of the pooled object
public abstract class Recycler<T> extends java.lang.Object
Light-weight object pool based on a thread-local stack.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Recycler.BlockingMessageQueue<T>
This is an implementation ofMessagePassingQueue
, similar to what might be returned fromPlatformDependent.newMpscQueue(int)
, but intended to be used for debugging purpose.private static class
Recycler.DefaultHandle<T>
static class
Recycler.EnhancedHandle<T>
static interface
Recycler.Handle<T>
private static class
Recycler.LocalPool<T>
-
Field Summary
Fields Modifier and Type Field Description private static boolean
BATCH_FAST_TL_ONLY
private static boolean
BLOCKING_POOL
private int
chunkSize
private static int
DEFAULT_INITIAL_MAX_CAPACITY_PER_THREAD
private static int
DEFAULT_MAX_CAPACITY_PER_THREAD
private static int
DEFAULT_QUEUE_CHUNK_SIZE_PER_THREAD
private int
interval
private static InternalLogger
logger
private int
maxCapacityPerThread
private static Recycler.EnhancedHandle<?>
NOOP_HANDLE
private static int
RATIO
private FastThreadLocal<Recycler.LocalPool<T>>
threadLocal
-
Constructor Summary
Constructors Modifier Constructor Description protected
Recycler()
protected
Recycler(int maxCapacityPerThread)
protected
Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor)
Deprecated.protected
Recycler(int maxCapacityPerThread, int ratio, int chunkSize)
protected
Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor, int ratio, int maxDelayedQueuesPerThread)
Deprecated.protected
Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor, int ratio, int maxDelayedQueuesPerThread, int delayedQueueRatio)
Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
get()
protected abstract T
newObject(Recycler.Handle<T> handle)
boolean
recycle(T o, Recycler.Handle<T> handle)
Deprecated.(package private) int
threadLocalSize()
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
NOOP_HANDLE
private static final Recycler.EnhancedHandle<?> NOOP_HANDLE
-
DEFAULT_INITIAL_MAX_CAPACITY_PER_THREAD
private static final int DEFAULT_INITIAL_MAX_CAPACITY_PER_THREAD
- See Also:
- Constant Field Values
-
DEFAULT_MAX_CAPACITY_PER_THREAD
private static final int DEFAULT_MAX_CAPACITY_PER_THREAD
-
RATIO
private static final int RATIO
-
DEFAULT_QUEUE_CHUNK_SIZE_PER_THREAD
private static final int DEFAULT_QUEUE_CHUNK_SIZE_PER_THREAD
-
BLOCKING_POOL
private static final boolean BLOCKING_POOL
-
BATCH_FAST_TL_ONLY
private static final boolean BATCH_FAST_TL_ONLY
-
maxCapacityPerThread
private final int maxCapacityPerThread
-
interval
private final int interval
-
chunkSize
private final int chunkSize
-
threadLocal
private final FastThreadLocal<Recycler.LocalPool<T>> threadLocal
-
-
Constructor Detail
-
Recycler
protected Recycler()
-
Recycler
protected Recycler(int maxCapacityPerThread)
-
Recycler
@Deprecated protected Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor)
Deprecated.
-
Recycler
@Deprecated protected Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor, int ratio, int maxDelayedQueuesPerThread)
Deprecated.
-
Recycler
@Deprecated protected Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor, int ratio, int maxDelayedQueuesPerThread, int delayedQueueRatio)
Deprecated.
-
Recycler
protected Recycler(int maxCapacityPerThread, int ratio, int chunkSize)
-
-
Method Detail
-
get
public final T get()
-
recycle
@Deprecated public final boolean recycle(T o, Recycler.Handle<T> handle)
Deprecated.
-
threadLocalSize
final int threadLocalSize()
-
newObject
protected abstract T newObject(Recycler.Handle<T> handle)
- Parameters:
handle
- can NOT be null.
-
-