Class Recycler<T>

java.lang.Object
io.netty.util.Recycler<T>
Type Parameters:
T - the type of the pooled object
Direct Known Subclasses:
AdaptivePoolingAllocator.Magazine.AdaptiveRecycler

public abstract class Recycler<T> extends Object
Light-weight object pool based on a thread-local stack.
  • Field Details

    • logger

      private static final InternalLogger logger
    • NOOP_HANDLE

      private static final Recycler.EnhancedHandle<?> NOOP_HANDLE
    • NOOP_LOCAL_POOL

      private static final Recycler.UnguardedLocalPool<?> NOOP_LOCAL_POOL
    • DEFAULT_INITIAL_MAX_CAPACITY_PER_THREAD

      private static final int DEFAULT_INITIAL_MAX_CAPACITY_PER_THREAD
      See Also:
    • 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
    • localPool

      private final Recycler.LocalPool<?,T> localPool
    • threadLocalPool

      private final FastThreadLocal<Recycler.LocalPool<?,T>> threadLocalPool
  • Constructor Details

    • Recycler

      protected Recycler(int maxCapacity, boolean unguarded)
      USE IT CAREFULLY!
      This is creating a shareable Recycler which get() can be called concurrently from different Threads.
      Usually Recyclers uses some form of thread-local storage, but this constructor is disabling it and using a single pool of instances instead, sized as maxCapacity
      This is NOT enforcing pooled instances states to be validated if unguarded = true: it means that ObjectPool.Handle.recycle(Object) is not checking that object is the same which was recycled and assume no other recycling happens concurrently (similar to what Recycler.EnhancedHandle.unguardedRecycle(Object) does).
    • Recycler

      protected Recycler(boolean unguarded)
      USE IT CAREFULLY!
      This is NOT enforcing pooled instances states to be validated if unguarded = true: it means that ObjectPool.Handle.recycle(Object) is not checking that object is the same which was recycled and assume no other recycling happens concurrently (similar to what Recycler.EnhancedHandle.unguardedRecycle(Object) does).
    • Recycler

      protected Recycler(Thread owner, boolean unguarded)
      USE IT CAREFULLY!
      This is NOT enforcing pooled instances states to be validated if unguarded = true as stated by Recycler(boolean) and allows to pin the recycler to a specific Thread, if owner is not null.

      Since this method has been introduced for performance-sensitive cases it doesn't validate if get() is called from the owner Thread: it assumes get() to never happen concurrently.

    • Recycler

      protected Recycler(int maxCapacityPerThread)
    • Recycler

      protected Recycler()
    • Recycler

      protected Recycler(int chunksSize, int maxCapacityPerThread, boolean unguarded)
      USE IT CAREFULLY!
      This is NOT enforcing pooled instances states to be validated if unguarded = true as stated by Recycler(boolean), but it allows to tune the chunk size used for local pooling.
    • Recycler

      protected Recycler(int chunkSize, int maxCapacityPerThread, Thread owner, boolean unguarded)
      USE IT CAREFULLY!
      This is NOT enforcing pooled instances states to be validated if unguarded = true and allows pinning the recycler to a specific Thread, as stated by Recycler(Thread, boolean).
      It also allows tuning the chunk size used for local pooling and the max capacity per thread.
      Throws:
      IllegalArgumentException - if owner is null.
    • Recycler

      @Deprecated protected Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor)
      Deprecated.
      Use one of the following instead: Recycler(), Recycler(int), Recycler(int, int, int).
    • Recycler

      @Deprecated protected Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor, int ratio, int maxDelayedQueuesPerThread)
      Deprecated.
      Use one of the following instead: Recycler(), Recycler(int), Recycler(int, int, int).
    • Recycler

      @Deprecated protected Recycler(int maxCapacityPerThread, int maxSharedCapacityFactor, int ratio, int maxDelayedQueuesPerThread, int delayedQueueRatio)
      Deprecated.
      Use one of the following instead: Recycler(), Recycler(int), Recycler(int, int, int).
    • Recycler

      protected Recycler(int maxCapacityPerThread, int interval, int chunkSize)
    • Recycler

      protected Recycler(int maxCapacityPerThread, int interval, int chunkSize, boolean unguarded)
      USE IT CAREFULLY!
      This is NOT enforcing pooled instances states to be validated if unguarded =true as stated by Recycler(boolean).
    • Recycler

      protected Recycler(int maxCapacityPerThread, int interval, int chunkSize, Thread owner, boolean unguarded)
      USE IT CAREFULLY!
      This is NOT enforcing pooled instances states to be validated if unguarded =true as stated by Recycler(boolean).
    • Recycler

      private Recycler(int maxCapacityPerThread, int ratio, int chunkSize, boolean useThreadLocalStorage, Thread owner, boolean unguarded)
  • Method Details