Class 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
    • 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
      • 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
      • 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.