Package one.nio.pool

Class Pool<T>

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Serializable, java.lang.AutoCloseable, java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Deque<T>, java.util.List<T>, java.util.Queue<T>
    Direct Known Subclasses:
    SocketPool

    public abstract class Pool<T>
    extends java.util.LinkedList<T>
    implements java.io.Closeable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Pool​(int initialCount, int maxCount, int timeout)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      T borrowObject()  
      void close()  
      abstract T createObject()  
      private void decreaseCount()  
      void destroyObject​(T object)  
      protected void initialize()  
      void invalidateAll()  
      void invalidateObject​(T object)  
      boolean isClosed()  
      java.lang.String name()  
      void returnObject​(T object)  
      • Methods inherited from class java.util.LinkedList

        add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArray
      • Methods inherited from class java.util.AbstractSequentialList

        iterator
      • Methods inherited from class java.util.AbstractList

        equals, hashCode, listIterator, removeRange, subList
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty, removeAll, retainAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.util.Deque

        iterator
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
    • Field Detail

      • closed

        protected boolean closed
      • keepEmpty

        protected boolean keepEmpty
      • fifo

        protected boolean fifo
      • initialCount

        protected int initialCount
      • createdCount

        protected int createdCount
      • maxCount

        protected int maxCount
      • timeout

        protected int timeout
      • timeouts

        protected int timeouts
      • waitingThreads

        protected int waitingThreads
    • Constructor Detail

      • Pool

        protected Pool​(int initialCount,
                       int maxCount,
                       int timeout)
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • name

        public java.lang.String name()
      • isClosed

        public boolean isClosed()
      • destroyObject

        public void destroyObject​(T object)
      • borrowObject

        public final T borrowObject()
                             throws PoolException,
                                    java.lang.InterruptedException
        Throws:
        PoolException
        java.lang.InterruptedException
      • returnObject

        public final void returnObject​(T object)
      • invalidateObject

        public final void invalidateObject​(T object)
      • invalidateAll

        public final void invalidateAll()
      • initialize

        protected final void initialize()
      • decreaseCount

        private void decreaseCount()