Top Description Inners Methods
com.fasterxml.jackson.core.util

public Interface RecyclerPool<P extends RecyclerPool.WithPool<P>>

extends Serializable
Known Direct Implementers
com.fasterxml.jackson.core.util.RecyclerPool.ThreadLocalPoolBase, com.fasterxml.jackson.core.util.RecyclerPool.NonRecyclingPoolBase, com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase
Type Parameters
<P>
Type of Objects pool recycles
Imports
java.io.Serializable, java.util.Deque, .Optional, java.util.concurrent.ArrayBlockingQueue, .ConcurrentLinkedDeque, java.util.concurrent.atomic.AtomicReference

API for object pools that control creation and possible reuse of objects that are costly to create (often things like encoding/decoding buffers).

Also contains partial (base) implementations for pools that use different strategies on retaining objects for reuse. Following implementations are included:

Default implementations are also included as nested classes.

Since
2.16

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
RecyclerPool.BoundedPoolBase<P extends RecyclerPool.WithPool<P>>

RecyclerPool implementation that uses a bounded queue (ArrayBlockingQueue for recycling instances.

public abstract static class
RecyclerPool.ConcurrentDequePoolBase<P extends RecyclerPool.WithPool<P>>

RecyclerPool implementation that uses ConcurrentLinkedDeque for recycling instances.

public abstract static class
RecyclerPool.LockFreePoolBase<P extends RecyclerPool.WithPool<P>>

Deprecated Since 2.18: use other implementations
RecyclerPool implementation that uses a lock free linked list for recycling instances.
public abstract static class
RecyclerPool.NonRecyclingPoolBase<P extends RecyclerPool.WithPool<P>>

RecyclerPool implementation that does not use any pool but simply creates new instances when necessary.

public abstract 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.

public abstract static class
RecyclerPool.ThreadLocalPoolBase<P extends RecyclerPool.WithPool<P>>

Default RecyclerPool implementation that uses ThreadLocal for recycling instances.

public static interface
RecyclerPool.WithPool<
Self type
P extends RecyclerPool.WithPool<P>
>

Simple add-on interface that poolable entities must implement.

Method Summary

Modifier and TypeMethod and Description
public default P

Returns:

Pooled instance for caller to use; caller expected to call releasePooled after it is done using instance.
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) later after usage ends.

public P

Returns:

Instance acquired (pooled or just constructed)
acquirePooled
()

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

public default boolean

Returns:

true If pool supports operation and dropped all pooled Objects; false otherwise.
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.

public default int

Returns:

Number of pooled entries available from this pool, if available; -1 if not.
pooledCount
()

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling.

public void
releasePooled(P
Pooled instance to release back to pool
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.

Method Detail

acquireAndLinkPooledback to summary
public 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) later after usage ends. Actual acquisition is done by a call to acquirePooled().

Default implementation calls acquirePooled() followed by a call to WithPool#withPool.

Returns:P

Pooled instance for caller to use; caller expected to call releasePooled after it is done using instance.

acquirePooledback to summary
public P acquirePooled()

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

Returns:P

Instance acquired (pooled or just constructed)

clearback to summary
public default 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.

Returns:boolean

true If pool supports operation and dropped all pooled Objects; false otherwise.

Since
2.17
pooledCountback to summary
public default int pooledCount()

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling. Note that in addition to this information possibly not being available (denoted by return value of -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.

Returns:int

Number of pooled entries available from this pool, if available; -1 if not.

Since
2.18
releasePooledback to summary
public 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.

Parameters
pooled:P

Pooled instance to release back to pool

com.fasterxml.jackson.core.util back to summary

public abstract Class RecyclerPool.BoundedPoolBase<P extends RecyclerPool.WithPool<P>>

extends RecyclerPool.StatefulImplBase<P extends RecyclerPool.WithPool<P>>
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.core.util.JsonRecyclerPools.BoundedPool

RecyclerPool implementation that uses a bounded queue (ArrayBlockingQueue for recycling instances. This is "bounded" pool since it will never hold on to more pooled instances than its size configuration: the default size is BoundedPoolBase#DEFAULT_CAPACITY.

Field Summary

Modifier and TypeField and Description
private final transient int
public static final int
DEFAULT_CAPACITY

Default capacity which limits number of items that are ever retained for reuse.

private final transient ArrayBlockingQueue<P>
private static final long
Inherited from com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase:
_serializationSERIALIZATION_NON_SHAREDSERIALIZATION_SHARED

Constructor Summary

AccessConstructor and Description
protected
BoundedPoolBase(int capacityAsId)

Method Summary

Modifier and TypeMethod and Description
public P
acquirePooled()

Implements com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

public int
public boolean
clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.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.

public int
pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling.

public void
releasePooled(P
Pooled instance to release back to pool
pooled
)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Inherited from com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase:
_resolveToSharedcreatePooled

Field Detail

capacityback to summary
private final transient int capacity
DEFAULT_CAPACITYback to summary
public static final int DEFAULT_CAPACITY

Default capacity which limits number of items that are ever retained for reuse.

poolback to summary
private final transient ArrayBlockingQueue<P> pool
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase.serialVersionUID.

Constructor Detail

BoundedPoolBaseback to summary
protected BoundedPoolBase(int capacityAsId)

Method Detail

acquirePooledback to summary
public P acquirePooled()

Implements com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

Returns:P

Instance acquired (pooled or just constructed)

Annotations
@Override
capacityback to summary
public int capacity()
clearback to summary
public boolean clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.clear.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.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.

Returns:boolean

true If pool supports operation and dropped all pooled Objects; false otherwise.

Annotations
@Override
pooledCountback to summary
public int pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling. Note that in addition to this information possibly not being available (denoted by return value of -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.

Returns:int

Number of pooled entries available from this pool, if available; -1 if not.

Annotations
@Override
releasePooledback to summary
public void releasePooled(P pooled)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Parameters
pooled:P

Pooled instance to release back to pool

Annotations
@Override
com.fasterxml.jackson.core.util back to summary

public abstract Class RecyclerPool.ConcurrentDequePoolBase<P extends RecyclerPool.WithPool<P>>

extends RecyclerPool.StatefulImplBase<P extends RecyclerPool.WithPool<P>>
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.core.util.JsonRecyclerPools.ConcurrentDequePool

RecyclerPool implementation that uses ConcurrentLinkedDeque for recycling instances.

Pool is unbounded: see RecyclerPool what this means.

Field Summary

Modifier and TypeField and Description
protected final transient Deque<P>
private static final long
Inherited from com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase:
_serializationSERIALIZATION_NON_SHAREDSERIALIZATION_SHARED

Constructor Summary

AccessConstructor and Description
protected
ConcurrentDequePoolBase(int serialization)

Method Summary

Modifier and TypeMethod and Description
public P
acquirePooled()

Implements com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

public boolean
clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.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.

public int
pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling.

public void
releasePooled(P
Pooled instance to release back to pool
pooled
)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Inherited from com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase:
_resolveToSharedcreatePooled

Field Detail

poolback to summary
protected final transient Deque<P> pool
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase.serialVersionUID.

Constructor Detail

ConcurrentDequePoolBaseback to summary
protected ConcurrentDequePoolBase(int serialization)

Method Detail

acquirePooledback to summary
public P acquirePooled()

Implements com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

Returns:P

Instance acquired (pooled or just constructed)

Annotations
@Override
clearback to summary
public boolean clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.clear.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.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.

Returns:boolean

true If pool supports operation and dropped all pooled Objects; false otherwise.

Annotations
@Override
pooledCountback to summary
public int pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling. Note that in addition to this information possibly not being available (denoted by return value of -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.

Returns:int

Number of pooled entries available from this pool, if available; -1 if not.

Annotations
@Override
releasePooledback to summary
public void releasePooled(P pooled)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Parameters
pooled:P

Pooled instance to release back to pool

Annotations
@Override
com.fasterxml.jackson.core.util back to summary

public abstract Class RecyclerPool.LockFreePoolBase<P extends RecyclerPool.WithPool<P>>

extends RecyclerPool.StatefulImplBase<P extends RecyclerPool.WithPool<P>>
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.core.util.JsonRecyclerPools.LockFreePool
Annotations
@Deprecated

Deprecated

Since 2.18: use other implementations

RecyclerPool implementation that uses a lock free linked list for recycling instances. Pool is unbounded: see RecyclerPool for details on what this means.

Note

serious issues found with 2.17.0 lead to deprecation of this implementation -- basically it is possible to have unbalanced acquire/release success rate lead to excessive growth of pooled instances. See jackson-core#1260 for details.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
private final transient AtomicReference<RecyclerPool.LockFreePoolBase.Node<P>>
private static final long
Inherited from com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase:
_serializationSERIALIZATION_NON_SHAREDSERIALIZATION_SHARED

Constructor Summary

AccessConstructor and Description
protected
LockFreePoolBase(int serialization)

Method Summary

Modifier and TypeMethod and Description
public P
acquirePooled()

Implements com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

public boolean
clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.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.

public int
pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling.

public void
releasePooled(P
Pooled instance to release back to pool
pooled
)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Inherited from com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase:
_resolveToSharedcreatePooled

Field Detail

headback to summary
private final transient AtomicReference<RecyclerPool.LockFreePoolBase.Node<P>> head
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase.serialVersionUID.

Constructor Detail

LockFreePoolBaseback to summary
protected LockFreePoolBase(int serialization)

Method Detail

acquirePooledback to summary
public P acquirePooled()

Implements com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

Returns:P

Instance acquired (pooled or just constructed)

Annotations
@Override
clearback to summary
public boolean clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.clear.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.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.

Returns:boolean

true If pool supports operation and dropped all pooled Objects; false otherwise.

Annotations
@Override
pooledCountback to summary
public int pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling. Note that in addition to this information possibly not being available (denoted by return value of -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.

Returns:int

Number of pooled entries available from this pool, if available; -1 if not.

Annotations
@Override
releasePooledback to summary
public void releasePooled(P pooled)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Parameters
pooled:P

Pooled instance to release back to pool

Annotations
@Override
com.fasterxml.jackson.core.util back to summary

protected Class RecyclerPool.LockFreePoolBase.Node<P>

extends Object
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.core.util.RecyclerPool.LockFreePoolBase.Node

Field Summary

Modifier and TypeField and Description
pack-priv RecyclerPool.LockFreePoolBase.Node<P>
pack-priv final P

Constructor Summary

AccessConstructor and Description
pack-priv
Node(P value)

Field Detail

nextback to summary
pack-priv RecyclerPool.LockFreePoolBase.Node<P> next
valueback to summary
pack-priv final P value

Constructor Detail

Nodeback to summary
pack-priv Node(P value)
com.fasterxml.jackson.core.util back to summary

public abstract Class RecyclerPool.NonRecyclingPoolBase<P extends RecyclerPool.WithPool<P>>

extends Object
implements RecyclerPool<P extends RecyclerPool.WithPool<P>>
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.core.util.RecyclerPool.NonRecyclingPoolBase
All Implemented Interfaces
com.fasterxml.jackson.core.util.RecyclerPool, java.io.Serializable
Known Direct Subclasses
com.fasterxml.jackson.core.util.JsonRecyclerPools.NonRecyclingPool

RecyclerPool implementation that does not use any pool but simply creates new instances when necessary.

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public P
acquireAndLinkPooled()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.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) later after usage ends.

public abstract P
acquirePooled()

Redeclares com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

public boolean

Returns:

Always returns true
clear
()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.clear.

Although no pooling occurs, we consider clearing to succeed, so returns always true.

public int
pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling.

public void
releasePooled(P
Pooled instance to release back to pool
pooled
)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

NonRecyclingPoolBaseback to summary
public NonRecyclingPoolBase()

Method Detail

acquireAndLinkPooledback to summary
public P acquireAndLinkPooled()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.acquireAndLinkPooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.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) later after usage ends. Actual acquisition is done by a call to acquirePooled().

Default implementation calls acquirePooled() followed by a call to WithPool#withPool.

Returns:P

Pooled instance for caller to use; caller expected to call releasePooled after it is done using instance.

Annotations
@Override
acquirePooledback to summary
public abstract P acquirePooled()

Redeclares com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

Returns:P

Instance acquired (pooled or just constructed)

Annotations
@Override
clearback to summary
public boolean clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.clear.

Although no pooling occurs, we consider clearing to succeed, so returns always true.

Returns:boolean

Always returns true

Annotations
@Override
pooledCountback to summary
public int pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling. Note that in addition to this information possibly not being available (denoted by return value of -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.

Returns:int

Number of pooled entries available from this pool, if available; -1 if not.

Annotations
@Override
releasePooledback to summary
public void releasePooled(P pooled)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Parameters
pooled:P

Pooled instance to release back to pool

Annotations
@Override
com.fasterxml.jackson.core.util back to summary

public abstract Class RecyclerPool.StatefulImplBase<P extends RecyclerPool.WithPool<P>>

extends Object
implements RecyclerPool<P extends RecyclerPool.WithPool<P>>
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.core.util.RecyclerPool.StatefulImplBase
All Implemented Interfaces
com.fasterxml.jackson.core.util.RecyclerPool, java.io.Serializable
Known Direct Subclasses
com.fasterxml.jackson.core.util.RecyclerPool.ConcurrentDequePoolBase, com.fasterxml.jackson.core.util.RecyclerPool.LockFreePoolBase, com.fasterxml.jackson.core.util.RecyclerPool.BoundedPoolBase

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.

Field Summary

Modifier and TypeField and Description
protected final int
_serialization

Value that indicates basic aspects of pool for JDK serialization; either marker for shared/non-shared, or possibly bounded size; depends on sub-class.

public static final int
public static final int
private static final long

Constructor Summary

AccessConstructor and Description
protected
StatefulImplBase(int serialization)

Method Summary

Modifier and TypeMethod and Description
protected Optional<RecyclerPool.StatefulImplBase<P>>
public abstract P
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_serializationback to summary
protected final int _serialization

Value that indicates basic aspects of pool for JDK serialization; either marker for shared/non-shared, or possibly bounded size; depends on sub-class.

SERIALIZATION_NON_SHAREDback to summary
public static final int SERIALIZATION_NON_SHARED
SERIALIZATION_SHAREDback to summary
public static final int SERIALIZATION_SHARED
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

StatefulImplBaseback to summary
protected StatefulImplBase(int serialization)

Method Detail

_resolveToSharedback to summary
protected Optional<RecyclerPool.StatefulImplBase<P>> _resolveToShared(RecyclerPool.StatefulImplBase<P> shared)
createPooledback to summary
public abstract P createPooled()
com.fasterxml.jackson.core.util back to summary

public abstract Class RecyclerPool.ThreadLocalPoolBase<P extends RecyclerPool.WithPool<P>>

extends Object
implements RecyclerPool<P extends RecyclerPool.WithPool<P>>
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.core.util.RecyclerPool.ThreadLocalPoolBase
All Implemented Interfaces
com.fasterxml.jackson.core.util.RecyclerPool, java.io.Serializable
Known Direct Subclasses
com.fasterxml.jackson.core.util.JsonRecyclerPools.ThreadLocalPool

Default RecyclerPool implementation that uses ThreadLocal for recycling instances. Instances are stored using java.lang.ref.SoftReferences so that they may be Garbage Collected as needed by JVM.

Note that this implementation may not work well on platforms where java.lang.ref.SoftReferences are not well supported (like Android), or on platforms where java.lang.Threads are not long-living or reused (like Project Loom).

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public P
acquireAndLinkPooled()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.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) later after usage ends.

public abstract P
acquirePooled()

Redeclares com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

public boolean
clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.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.

public int
pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling.

public void
releasePooled(P
Pooled instance to release back to pool
pooled
)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ThreadLocalPoolBaseback to summary
protected ThreadLocalPoolBase()

Method Detail

acquireAndLinkPooledback to summary
public P acquireAndLinkPooled()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.acquireAndLinkPooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.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) later after usage ends. Actual acquisition is done by a call to acquirePooled().

Default implementation calls acquirePooled() followed by a call to WithPool#withPool.

Returns:P

Pooled instance for caller to use; caller expected to call releasePooled after it is done using instance.

Annotations
@Override
acquirePooledback to summary
public abstract P acquirePooled()

Redeclares com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.acquirePooled.

Method for sub-classes to implement for actual acquire logic; called by acquireAndLinkPooled().

Returns:P

Instance acquired (pooled or just constructed)

Annotations
@Override
clearback to summary
public boolean clear()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.clear.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.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.

Returns:boolean

true If pool supports operation and dropped all pooled Objects; false otherwise.

Annotations
@Override
pooledCountback to summary
public int pooledCount()

Overrides default com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.pooledCount.

Diagnostic method for obtaining an estimate of number of pooled items this pool contains, available for recycling. Note that in addition to this information possibly not being available (denoted by return value of -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.

Returns:int

Number of pooled entries available from this pool, if available; -1 if not.

Annotations
@Override
releasePooledback to summary
public void releasePooled(P pooled)

Implements com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

Doc from com.fasterxml.jackson.core.util.RecyclerPool.releasePooled.

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.

Parameters
pooled:P

Pooled instance to release back to pool

Annotations
@Override
com.fasterxml.jackson.core.util back to summary

public Interface RecyclerPool.WithPool<P extends RecyclerPool.WithPool<P>>

Known Direct Implementers
com.fasterxml.jackson.core.util.BufferRecycler
Type Parameters
<P>
Self type

Simple add-on interface that poolable entities must implement.

Method Summary

Modifier and TypeMethod and Description
public void
releaseToPool()

Method called when this item is to be released back to the pool that owns it (if any)

public P

Returns:

This item (for call chaining)
withPool
(RecyclerPool<P>
Pool that "owns" pooled item
pool
)

Method to call to add link from pooled item back to pool that handles it

Method Detail

releaseToPoolback to summary
public void releaseToPool()

Method called when this item is to be released back to the pool that owns it (if any)

withPoolback to summary
public P withPool(RecyclerPool<P> pool)

Method to call to add link from pooled item back to pool that handles it

Parameters
pool:RecyclerPool<P>

Pool that "owns" pooled item

Returns:P

This item (for call chaining)