public abstract static class RecyclerPool.ThreadLocalPoolBase<P extends RecyclerPool.WithPool<P>> extends Object implements RecyclerPool<P>
RecyclerPool implementation that uses
ThreadLocal for recycling instances.
Instances are stored using SoftReferences so that
they may be Garbage Collected as needed by JVM.
Note that this implementation may not work well on platforms where
SoftReferences are not well supported (like
Android), or on platforms where Threads are not
long-living or reused (like Project Loom).
RecyclerPool.BoundedPoolBase<P extends RecyclerPool.WithPool<P>>, RecyclerPool.ConcurrentDequePoolBase<P extends RecyclerPool.WithPool<P>>, RecyclerPool.LockFreePoolBase<P extends RecyclerPool.WithPool<P>>, RecyclerPool.NonRecyclingPoolBase<P extends RecyclerPool.WithPool<P>>, RecyclerPool.StatefulImplBase<P extends RecyclerPool.WithPool<P>>, RecyclerPool.ThreadLocalPoolBase<P extends RecyclerPool.WithPool<P>>, RecyclerPool.WithPool<P extends RecyclerPool.WithPool<P>>| Modifier | Constructor and Description |
|---|---|
protected |
ThreadLocalPoolBase() |
| Modifier and Type | Method and Description |
|---|---|
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 RecyclerPool.releasePooled(P)) later after usage ends. |
abstract P |
acquirePooled()
Method for sub-classes to implement for actual acquire logic; called
by
RecyclerPool.acquireAndLinkPooled(). |
boolean |
clear()
Optional method that may allow dropping of all pooled Objects; mostly
useful for unbounded pool implementations that may retain significant
memory and that may then be cleared regularly.
|
int |
pooledCount()
Diagnostic method for obtaining an estimate of number of pooled items
this pool contains, available for recycling.
|
void |
releasePooled(P pooled)
Method that should be called when previously acquired (see
RecyclerPool.acquireAndLinkPooled())
pooled value that is no longer needed; this lets pool to take ownership
for possible reuse. |
public P acquireAndLinkPooled()
RecyclerPoolRecyclerPool as necessary for it to be
released (see RecyclerPool.releasePooled(P)) later after usage ends.
Actual acquisition is done by a call to RecyclerPool.acquirePooled().
Default implementation calls RecyclerPool.acquirePooled() followed by
a call to RecyclerPool.WithPool.withPool(com.fasterxml.jackson.core.util.RecyclerPool<P>).
acquireAndLinkPooled in interface RecyclerPool<P extends RecyclerPool.WithPool<P>>RecyclerPool.releasePooled(P) after it is done using instance.public abstract P acquirePooled()
RecyclerPoolRecyclerPool.acquireAndLinkPooled().acquirePooled in interface RecyclerPool<P extends RecyclerPool.WithPool<P>>public void releasePooled(P pooled)
RecyclerPoolRecyclerPool.acquireAndLinkPooled())
pooled value that is no longer needed; this lets pool to take ownership
for possible reuse.releasePooled in interface RecyclerPool<P extends RecyclerPool.WithPool<P>>pooled - Pooled instance to release back to poolpublic int pooledCount()
RecyclerPool-1) even when available this may be
just an approximation.
Default method implementation simply returns -1 and is meant to be
overridden by concrete sub-classes.
pooledCount in interface RecyclerPool<P extends RecyclerPool.WithPool<P>>-1 if not.public boolean clear()
RecyclerPoolclear in interface RecyclerPool<P extends RecyclerPool.WithPool<P>>true If pool supports operation and dropped all pooled
Objects; false otherwise.Copyright © 2008–2024 FasterXML. All rights reserved.