Class VirtualThreadAwareRecyclerPool

java.lang.Object
io.micronaut.serde.jackson.VirtualThreadAwareRecyclerPool
All Implemented Interfaces:
Serializable, tools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>

@Internal public final class VirtualThreadAwareRecyclerPool extends Object implements tools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
A Jackson BufferRecycler pool that keeps a recycler per platform thread, and shares recyclers between virtual threads.

A thread local pool never reuses a recycler on virtual threads, which are usually created for one task each: every parser and generator would allocate new buffers. Virtual threads therefore take recyclers from a concurrent deque pool, and give them back to it when their parser or generator is closed. The concurrent deque pool is created when a virtual thread first asks for a recycler.

Since:
3.3.0
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface tools.jackson.core.util.RecyclerPool

    tools.jackson.core.util.RecyclerPool.BoundedPoolBase<P>, tools.jackson.core.util.RecyclerPool.ConcurrentDequePoolBase<P>, tools.jackson.core.util.RecyclerPool.NonRecyclingPoolBase<P>, tools.jackson.core.util.RecyclerPool.StatefulImplBase<P>, tools.jackson.core.util.RecyclerPool.ThreadLocalPoolBase<P>, tools.jackson.core.util.RecyclerPool.WithPool<P>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a pool that uses JsonRecyclerPools.threadLocalPool() on platform threads and a new concurrent deque pool on virtual threads.
  • Method Summary

    Modifier and Type
    Method
    Description
    tools.jackson.core.util.BufferRecycler
     
    tools.jackson.core.util.BufferRecycler
     
    boolean
     
    int
     
    void
    releasePooled(tools.jackson.core.util.BufferRecycler pooled)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VirtualThreadAwareRecyclerPool

      public VirtualThreadAwareRecyclerPool()
      Creates a pool that uses JsonRecyclerPools.threadLocalPool() on platform threads and a new concurrent deque pool on virtual threads.
  • Method Details

    • acquireAndLinkPooled

      public tools.jackson.core.util.BufferRecycler acquireAndLinkPooled()
      Specified by:
      acquireAndLinkPooled in interface tools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
    • acquirePooled

      public tools.jackson.core.util.BufferRecycler acquirePooled()
      Specified by:
      acquirePooled in interface tools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
    • releasePooled

      public void releasePooled(tools.jackson.core.util.BufferRecycler pooled)
      Specified by:
      releasePooled in interface tools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
    • pooledCount

      public int pooledCount()
      Specified by:
      pooledCount in interface tools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
    • clear

      public boolean clear()
      Specified by:
      clear in interface tools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>