Package org.apache.commons.pool.impl
Class GenericKeyedObjectPool.Latch<LK,LV>
- java.lang.Object
-
- org.apache.commons.pool.impl.GenericKeyedObjectPool.Latch<LK,LV>
-
- Enclosing class:
- GenericKeyedObjectPool<K,V>
private final class GenericKeyedObjectPool.Latch<LK,LV> extends java.lang.Object
Latch used to control allocation order of objects to threads to ensure fairness. That is, for each key, objects are allocated to threads in the order that threads request objects.- Since:
- 1.5
-
-
Field Summary
Fields Modifier and Type Field Description private LK
_key
key of associated poolprivate boolean
_mayCreate
indicates that this latch can create an instanceprivate GenericKeyedObjectPool.ObjectTimestampPair<LV>
_pair
holds an ObjectTimestampPair when this latch has been allocated an instanceprivate GenericKeyedObjectPool.ObjectQueue
_pool
keyed pool associated with this latch
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private LK
getkey()
Retuns the key of the associated poolprivate GenericKeyedObjectPool.ObjectTimestampPair<LV>
getPair()
Gets the ObjectTimestampPair allocated to this latch.private GenericKeyedObjectPool.ObjectQueue
getPool()
Returns the pool associated with this latchprivate boolean
mayCreate()
Whether or not this latch can create an instanceprivate void
reset()
Reset the latch data.private void
setMayCreate(boolean mayCreate)
Sets the mayCreate propertyprivate void
setPair(GenericKeyedObjectPool.ObjectTimestampPair<LV> pair)
Allocate an ObjectTimestampPair to this latch.private void
setPool(GenericKeyedObjectPool.ObjectQueue pool)
Sets the pool associated with this latch
-
-
-
Field Detail
-
_key
private final LK _key
key of associated pool
-
_pool
private GenericKeyedObjectPool.ObjectQueue _pool
keyed pool associated with this latch
-
_pair
private GenericKeyedObjectPool.ObjectTimestampPair<LV> _pair
holds an ObjectTimestampPair when this latch has been allocated an instance
-
_mayCreate
private boolean _mayCreate
indicates that this latch can create an instance
-
-
Constructor Detail
-
Latch
private Latch(LK key)
Create a latch with the given key- Parameters:
key
- key of the pool associated with this latch
-
-
Method Detail
-
getkey
private LK getkey()
Retuns the key of the associated pool- Returns:
- associated pool key
-
getPool
private GenericKeyedObjectPool.ObjectQueue getPool()
Returns the pool associated with this latch- Returns:
- pool
-
setPool
private void setPool(GenericKeyedObjectPool.ObjectQueue pool)
Sets the pool associated with this latch- Parameters:
pool
- the pool
-
getPair
private GenericKeyedObjectPool.ObjectTimestampPair<LV> getPair()
Gets the ObjectTimestampPair allocated to this latch. Returns null if this latch does not have an instance allocated to it.- Returns:
- the associated ObjectTimestampPair
-
setPair
private void setPair(GenericKeyedObjectPool.ObjectTimestampPair<LV> pair)
Allocate an ObjectTimestampPair to this latch.- Parameters:
pair
- ObjectTimestampPair on this latch
-
mayCreate
private boolean mayCreate()
Whether or not this latch can create an instance- Returns:
- true if this latch has an instance creation permit
-
setMayCreate
private void setMayCreate(boolean mayCreate)
Sets the mayCreate property- Parameters:
mayCreate
- true means this latch can create an instance
-
reset
private void reset()
Reset the latch data. Used when an allocation fails and the latch needs to be re-added to the queue.
-
-