Class Pool.MultiEntry

  • Enclosing class:
    Pool<T>

    class Pool.MultiEntry
    extends Pool.Entry

    A Pool entry that holds metadata and a pooled object, that can be acquired concurrently multiple times, and can be acquired/released multiple times.

    • Constructor Summary

      Constructors 
      Constructor Description
      MultiEntry()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) int getUsageCount()  
      boolean isClosed()  
      boolean isIdle()  
      (package private) boolean isIdleAndOverUsed()  
      boolean isInUse()  
      boolean isOverUsed()  
      boolean isReserved()  
      (package private) void setUsageCount​(int usageCount)  
      java.lang.String toString()  
      (package private) boolean tryAcquire()
      Tries to acquire the entry if possible by incrementing both the usage count and the multiplex count.
      protected boolean tryEnable​(boolean acquire)
      Tries to enable, and possible also acquire, this Entry.
      (package private) boolean tryRelease()
      Tries to release the entry if possible by decrementing the multiplex count unless the entity is closed.
      (package private) boolean tryRemove()
      Tries to remove the entry by marking it as closed and decrementing the multiplex counter.
      • Methods inherited from class java.lang.Object

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

      • MultiEntry

        MultiEntry()
    • Method Detail

      • tryEnable

        protected boolean tryEnable​(boolean acquire)
        Description copied from class: Pool.Entry

        Tries to enable, and possible also acquire, this Entry.

        Specified by:
        tryEnable in class Pool.Entry
        Parameters:
        acquire - whether to also acquire this Entry
        Returns:
        whether this Entry was enabled
      • tryAcquire

        boolean tryAcquire()

        Tries to acquire the entry if possible by incrementing both the usage count and the multiplex count.

        Specified by:
        tryAcquire in class Pool.Entry
        Returns:
        true if the usage count is less than Pool.getMaxUsageCount() and the multiplex count is less than Pool.getMaxMultiplex(Object) and the entry is not closed, false otherwise.
      • tryRelease

        boolean tryRelease()

        Tries to release the entry if possible by decrementing the multiplex count unless the entity is closed.

        Specified by:
        tryRelease in class Pool.Entry
        Returns:
        true if the entry was released, false if tryRemove() should be called.
      • tryRemove

        boolean tryRemove()

        Tries to remove the entry by marking it as closed and decrementing the multiplex counter.

        The multiplex counter will never go below zero and if it reaches zero, the entry is considered removed.

        Specified by:
        tryRemove in class Pool.Entry
        Returns:
        true if the entry can be removed from the containing pool, false otherwise.
      • isClosed

        public boolean isClosed()
        Specified by:
        isClosed in class Pool.Entry
        Returns:
        whether this Entry is closed
      • isReserved

        public boolean isReserved()
        Specified by:
        isReserved in class Pool.Entry
        Returns:
        whether this Entry is reserved
      • isIdle

        public boolean isIdle()
        Specified by:
        isIdle in class Pool.Entry
        Returns:
        whether this Entry is idle
      • isInUse

        public boolean isInUse()
        Specified by:
        isInUse in class Pool.Entry
        Returns:
        whether this entry is in use.
      • toString

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