@InterfaceAudience.Private public class SoftObjectPool<K,V> extends ObjectPool<K,V>
SoftReference based shared object pool.
The objects are kept in soft references and
associated with keys which are identified by the equals method.
The objects are created by ObjectFactory on demand.
The object creation is expected to be lightweight,
and the objects may be excessively created and discarded.
Thread safe.ObjectPool.ObjectFactory<K,V>DEFAULT_CONCURRENCY_LEVEL, DEFAULT_INITIAL_CAPACITY, referenceCache, staleRefQueue| 构造器和说明 |
|---|
SoftObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory) |
SoftObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory,
int initialCapacity) |
SoftObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory,
int initialCapacity,
int concurrencyLevel) |
| 限定符和类型 | 方法和说明 |
|---|---|
Reference<V> |
createReference(K key,
V obj)
Create a reference associated with the given object
|
K |
getReferenceKey(Reference<V> ref)
Get key of the given reference
|
get, purge, sizepublic SoftObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory)
public SoftObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory, int initialCapacity)
public SoftObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory, int initialCapacity, int concurrencyLevel)
public Reference<V> createReference(K key, V obj)
ObjectPoolcreateReference 在类中 ObjectPool<K,V>key - the key to store in the referenceobj - the object to associate withpublic K getReferenceKey(Reference<V> ref)
ObjectPoolgetReferenceKey 在类中 ObjectPool<K,V>ref - The referenceCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.