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>
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
FieldsModifier and TypeFieldDescriptionprivate final LK
key of associated poolprivate boolean
indicates that this latch can create an instanceholds an ObjectTimestampPair when this latch has been allocated an instanceprivate GenericKeyedObjectPool<K,
V>.ObjectQueue keyed pool associated with this latch -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate LK
getkey()
Retuns the key of the associated poolgetPair()
Gets the ObjectTimestampPair allocated to this latch.private GenericKeyedObjectPool<K,
V>.ObjectQueue getPool()
Returns the pool associated with this latchprivate boolean
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
Allocate an ObjectTimestampPair to this latch.private void
setPool
(GenericKeyedObjectPool<K, V>.ObjectQueue pool) Sets the pool associated with this latch
-
Field Details
-
_key
key of associated pool -
_pool
keyed pool associated with this latch -
_pair
holds an ObjectTimestampPair when this latch has been allocated an instance -
_mayCreate
private boolean _mayCreateindicates that this latch can create an instance
-
-
Constructor Details
-
Latch
Create a latch with the given key- Parameters:
key
- key of the pool associated with this latch
-
-
Method Details
-
getkey
Retuns the key of the associated pool- Returns:
- associated pool key
-
getPool
Returns the pool associated with this latch- Returns:
- pool
-
setPool
Sets the pool associated with this latch- Parameters:
pool
- the pool
-
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
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.
-