P
- Type of Objects pool recyclespublic interface RecyclerPool<P extends RecyclerPool.WithPool<P>> extends Serializable
Also contains partial (base) implementations for pools that use different strategies on retaining objects for reuse. Following implementations are included:
RecyclerPool.NonRecyclingPoolBase
which does not retain or recycle anything and
will always simply construct and return new instance when
acquireBufferRecycler
is called
RecyclerPool.ThreadLocalPoolBase
which uses ThreadLocal
to retain at most
1 object per Thread
.
RecyclerPool.BoundedPoolBase
is "bounded pool" and retains at most N objects (default value being
RecyclerPool.BoundedPoolBase.DEFAULT_CAPACITY
) at any given time.
RecyclerPool.ConcurrentDequePoolBase
, RecyclerPool.LockFreePoolBase
-- are "unbounded" and retain any number of objects released: in practice
it is at most the highest number of concurrently used BufferRecycler
s.
Default implementations are also included as nested classes.
Modifier and Type | Interface and Description |
---|---|
static class |
RecyclerPool.BoundedPoolBase<P extends RecyclerPool.WithPool<P>>
RecyclerPool implementation that uses
a bounded queue (ArrayBlockingQueue for recycling instances. |
static class |
RecyclerPool.ConcurrentDequePoolBase<P extends RecyclerPool.WithPool<P>>
RecyclerPool implementation that uses
ConcurrentLinkedDeque for recycling instances. |
static class |
RecyclerPool.LockFreePoolBase<P extends RecyclerPool.WithPool<P>>
RecyclerPool implementation that uses
a lock free linked list for recycling instances. |
static class |
RecyclerPool.NonRecyclingPoolBase<P extends RecyclerPool.WithPool<P>>
RecyclerPool implementation that does not use
any pool but simply creates new instances when necessary. |
static class |
RecyclerPool.StatefulImplBase<P extends RecyclerPool.WithPool<P>>
Intermediate base class for instances that are stateful and require
special handling with respect to JDK serialization, to retain
"global" reference distinct from non-shared ones.
|
static class |
RecyclerPool.ThreadLocalPoolBase<P extends RecyclerPool.WithPool<P>>
Default
RecyclerPool implementation that uses
ThreadLocal for recycling instances. |
static interface |
RecyclerPool.WithPool<P extends RecyclerPool.WithPool<P>>
Simple add-on interface that poolable entities must implement.
|
Modifier and Type | Method and Description |
---|---|
default P |
acquireAndLinkPooled()
Method called to acquire a Pooled value from this pool
AND make sure it is linked back to this
RecyclerPool as necessary for it to be
released (see releasePooled(P) ) later after usage ends. |
P |
acquirePooled()
Method for sub-classes to implement for actual acquire logic; called
by
acquireAndLinkPooled() . |
void |
releasePooled(P pooled)
Method that should be called when previously acquired (see
acquireAndLinkPooled() )
pooled value that is no longer needed; this lets pool to take ownership
for possible reuse. |
default P acquireAndLinkPooled()
RecyclerPool
as necessary for it to be
released (see releasePooled(P)
) later after usage ends.
Actual acquisition is done by a call to acquirePooled()
.
Default implementation calls acquirePooled()
followed by
a call to RecyclerPool.WithPool.withPool(com.fasterxml.jackson.core.util.RecyclerPool<P>)
.
releasePooled(P)
after it is done using instance.P acquirePooled()
acquireAndLinkPooled()
.void releasePooled(P pooled)
acquireAndLinkPooled()
)
pooled value that is no longer needed; this lets pool to take ownership
for possible reuse.pooled
- Pooled instance to release back to poolCopyright © 2008–2023 FasterXML. All rights reserved.