@InterfaceAudience.Private public class WeakObjectPool<K,V> extends ObjectPool<K,V>
WeakReference
based shared object pool.
The objects are kept in weak 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
构造器和说明 |
---|
WeakObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory) |
WeakObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory,
int initialCapacity) |
WeakObjectPool(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, size
public WeakObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory)
public WeakObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory, int initialCapacity)
public WeakObjectPool(ObjectPool.ObjectFactory<K,V> objectFactory, int initialCapacity, int concurrencyLevel)
public Reference<V> createReference(K key, V obj)
ObjectPool
createReference
在类中 ObjectPool<K,V>
key
- the key to store in the referenceobj
- the object to associate withpublic K getReferenceKey(Reference<V> ref)
ObjectPool
getReferenceKey
在类中 ObjectPool<K,V>
ref
- The referenceCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.