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
ConstructorsConstructorDescriptionCreates a pool that usesJsonRecyclerPools.threadLocalPool()on platform threads and a newconcurrent deque poolon virtual threads. -
Method Summary
Modifier and TypeMethodDescriptiontools.jackson.core.util.BufferRecyclertools.jackson.core.util.BufferRecyclerbooleanclear()intvoidreleasePooled(tools.jackson.core.util.BufferRecycler pooled)
-
Constructor Details
-
VirtualThreadAwareRecyclerPool
public VirtualThreadAwareRecyclerPool()Creates a pool that usesJsonRecyclerPools.threadLocalPool()on platform threads and a newconcurrent deque poolon virtual threads.
-
-
Method Details
-
acquireAndLinkPooled
public tools.jackson.core.util.BufferRecycler acquireAndLinkPooled()- Specified by:
acquireAndLinkPooledin interfacetools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
-
acquirePooled
public tools.jackson.core.util.BufferRecycler acquirePooled()- Specified by:
acquirePooledin interfacetools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
-
releasePooled
public void releasePooled(tools.jackson.core.util.BufferRecycler pooled) - Specified by:
releasePooledin interfacetools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
-
pooledCount
public int pooledCount()- Specified by:
pooledCountin interfacetools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
-
clear
public boolean clear()- Specified by:
clearin interfacetools.jackson.core.util.RecyclerPool<tools.jackson.core.util.BufferRecycler>
-