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 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 Details

  • Constructor Details

    • Latch

      private Latch(LK key)
      Create a latch with the given key
      Parameters:
      key - key of the pool associated with this latch
  • Method Details

    • getkey

      private LK getkey()
      Retuns the key of the associated pool
      Returns:
      associated pool key
    • getPool

      private GenericKeyedObjectPool<K,V>.ObjectQueue getPool()
      Returns the pool associated with this latch
      Returns:
      pool
    • setPool

      private void setPool(GenericKeyedObjectPool<K,V>.ObjectQueue pool)
      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

      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.