Package one.nio.pool
Class Pool<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.AbstractSequentialList<E>
-
- java.util.LinkedList<T>
-
- one.nio.pool.Pool<T>
-
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,Cloneable,Iterable<T>,Collection<T>,Deque<T>,List<T>,Queue<T>
- Direct Known Subclasses:
SocketPool
public abstract class Pool<T> extends LinkedList<T> implements Closeable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanclosedprotected intcreatedCountprotected booleanfifoprotected intinitialCountprotected booleankeepEmptyprotected intmaxCountprotected inttimeoutprotected inttimeoutsprotected intwaitingThreads-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPool(int initialCount, int maxCount, int timeout)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TborrowObject()voidclose()abstract TcreateObject()voiddestroyObject(T object)protected voidinitialize()voidinvalidateAll()voidinvalidateObject(T object)booleanisClosed()Stringname()voidreturnObject(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.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
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
name
public String name()
-
isClosed
public boolean isClosed()
-
createObject
public abstract T createObject() throws PoolException
- Throws:
PoolException
-
destroyObject
public void destroyObject(T object)
-
borrowObject
public final T borrowObject() throws PoolException, InterruptedException
- Throws:
PoolExceptionInterruptedException
-
returnObject
public final void returnObject(T object)
-
invalidateObject
public final void invalidateObject(T object)
-
invalidateAll
public final void invalidateAll()
-
initialize
protected final void initialize()
-
-