Class Pool.Entry

  • Enclosing class:
    Pool<T>

    public class Pool.Entry
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Entry()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean enable​(T pooled, boolean acquire)
      Enable a reserved entry Pool.Entry.
      T getPooled()  
      int getUsageCount()  
      boolean isClosed()  
      boolean isIdle()  
      boolean isInUse()  
      boolean isOverUsed()  
      boolean release()
      Release the entry.
      boolean remove()
      Remove the entry.
      java.lang.String toString()  
      (package private) boolean tryAcquire()
      Try to acquire the entry if possible by incrementing both the usage count and the multiplex count.
      (package private) boolean tryRelease()
      Try to release the entry if possible by decrementing the multiplexing count unless the entity is closed.
      (package private) boolean tryRemove()
      Try to mark the entry as removed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Entry

        Entry()
    • Method Detail

      • enable

        public boolean enable​(T pooled,
                              boolean acquire)
        Enable a reserved entry Pool.Entry. An entry returned from the Pool.reserve(int) method must be enabled with this method, once and only once, before it is usable by the pool. The entry may be enabled and not acquired, in which case it is immediately available to be acquired, potentially by another thread; or it can be enabled and acquired atomically so that no other thread can acquire it, although the acquire may still fail if the pool has been closed.
        Parameters:
        pooled - The pooled item for the entry
        acquire - If true the entry is atomically enabled and acquired.
        Returns:
        true If the entry was enabled.
        Throws:
        java.lang.IllegalStateException - if the entry was already enabled
      • getPooled

        public T getPooled()
      • release

        public boolean release()
        Release the entry. This is equivalent to calling Pool.release(Pool.Entry) passing this entry.
        Returns:
        true if released.
      • remove

        public boolean remove()
        Remove the entry. This is equivalent to calling Pool.remove(Pool.Entry) passing this entry.
        Returns:
        true if remove.
      • tryAcquire

        boolean tryAcquire()
        Try to acquire the entry if possible by incrementing both the usage count and the multiplex count.
        Returns:
        true if the usage count is <= maxUsageCount and the multiplex count is maxMultiplex and the entry is not closed, false otherwise.
      • tryRelease

        boolean tryRelease()
        Try to release the entry if possible by decrementing the multiplexing count unless the entity is closed.
        Returns:
        true if the entry was released, false if tryRemove() should be called.
      • isOverUsed

        public boolean isOverUsed()
      • tryRemove

        boolean tryRemove()
        Try to mark the entry as removed.
        Returns:
        true if the entry has to be removed from the containing pool, false otherwise.
      • isClosed

        public boolean isClosed()
      • isIdle

        public boolean isIdle()
      • isInUse

        public boolean isInUse()
      • getUsageCount

        public int getUsageCount()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object