Class AsyncPoolImpl<T>

    • Constructor Detail

      • AsyncPoolImpl

        public AsyncPoolImpl​(AsyncPool.LifeCycle<T> lifeCycle,
                             java.util.concurrent.Executor executor,
                             int maxConcurrentCreate,
                             int maxWaiters,
                             int minimumEntities,
                             int maximumEntities,
                             long maxIdleTime,
                             java.util.concurrent.TimeUnit maxIdleUnit)
    • Method Detail

      • createCallTracker

        protected CallTracker createCallTracker()
      • start

        public void start()
        Specified by:
        start in interface AsyncPool<T>
      • checkout

        protected java.util.concurrent.CompletableFuture<T> checkout​(@Nonnull
                                                                     java.util.concurrent.CompletableFuture<T> future,
                                                                     @Nonnull
                                                                     CallCompletion waiter)
      • acquire

        public java.util.concurrent.CompletableFuture<T> acquire()
        Specified by:
        acquire in interface AsyncPool<T>
      • acquire0

        protected final java.util.concurrent.CompletableFuture<T> acquire0()
      • release

        public void release​(T entity)
        Specified by:
        release in interface AsyncPool<T>
      • release0

        protected final void release0​(T entity)
      • dispose

        public void dispose​(T entity)
        Specified by:
        dispose in interface AsyncPool<T>
      • dispose0

        protected final void dispose0​(T entity)
      • size

        public int size()
        Specified by:
        size in interface AsyncPool<T>
      • isShutdown

        public boolean isShutdown()
        Returns true if this resource has been shut down.
        Specified by:
        isShutdown in interface ShutdownableResource
        Returns:
        true if this resource has been shut down
      • isTerminated

        public boolean isTerminated()
        Returns true if the resource has completed shutting down. Note that isTerminated is never true unless shutdown was called first.
        Specified by:
        isTerminated in interface ShutdownableResource
        Returns:
        true if the resource has completed shutting down.
      • shutdown

        public void shutdown()
        Starts the shutdown process. It is recommended to perform the actual shutdown activity in a separate thread from the thread that calls shutdown
        Specified by:
        shutdown in interface Shutdownable
      • shutdownPool

        public java.util.concurrent.CompletableFuture<java.lang.Void> shutdownPool()
        Specified by:
        shutdownPool in interface AsyncPool<T>
      • waitForShutdown

        public void waitForShutdown()
                             throws java.lang.InterruptedException,
                                    java.lang.IllegalStateException
        Waits for shutdown to complete
        Specified by:
        waitForShutdown in interface Shutdownable
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.lang.IllegalStateException - when the method is invoked when the shutdown has yet to be started
      • waitForShutdown

        public void waitForShutdown​(long timeoutInMs)
                             throws java.lang.InterruptedException,
                                    java.lang.IllegalStateException,
                                    java.util.concurrent.TimeoutException
        Waits for shutdown to complete with a timeout
        Specified by:
        waitForShutdown in interface Shutdownable
        Parameters:
        timeoutInMs - number of milliseconds to wait before throwing TimeoutException
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.lang.IllegalStateException - when the method is invoked when the shutdown has yet to be started
        java.util.concurrent.TimeoutException - when the operation times out