Interface Pool<P>
- Type Parameters:
 P- the type of the pooled objects
- All Known Implementing Classes:
 ConcurrentPool, LockedPool, Pool.Wrapper
A pool of objects, with support for multiplexing and several
optimized strategies plus an optional ThreadLocal cache
of the last released entry.
A Pool should be terminated when
it is no longer needed; once terminated, it cannot be used anymore.
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAPoolentry that holds metadata and a pooled object.static interfaceA factory forPoolinstances.static classA wrapper forPoolinstances. - 
Method Summary
Modifier and TypeMethodDescriptionacquire()Acquires an entry from the pool.default Pool.Entry<P> acquire(Function<Pool.Entry<P>, P> creator) Acquires an entry from the pool, reserving and creating a new entry if necessary.default intdefault intintdefault intdefault intbooleanreserve()Creates a new disabled slot into the pool.intsize()stream()Terminates thisPool. 
- 
Method Details
- 
reserve
Pool.Entry<P> reserve()Creates a new disabled slot into the pool.
The returned entry must ultimately have the
Pool.Entry.enable(Object, boolean)method called or be removed viaPool.Entry.remove().- Returns:
 - a disabled entry that is contained in the pool, or 
nullif the pool is terminated or if the pool cannot reserve an entry 
 - 
acquire
Pool.Entry<P> acquire()Acquires an entry from the pool.
Only enabled entries will be returned from this method and their
Pool.Entry.enable(Object, boolean)method must not be called.- Returns:
 - an entry from the pool or null if none is available.
 
 - 
acquire
Acquires an entry from the pool, reserving and creating a new entry if necessary.
- Parameters:
 creator- a function to create the pooled value for a reserved entry.- Returns:
 - an entry from the pool or null if none is available.
 
 - 
isTerminated
boolean isTerminated()- Returns:
 - whether this 
Poolhas been terminated - See Also:
 
 - 
terminate
Collection<Pool.Entry<P>> terminate()Terminates this
Pool.All the entries are marked as terminated and cannot be acquired nor released, but only removed.
The returned list of all entries may be iterated to perform additional operations on the pooled objects.
The pool cannot be used anymore after it is terminated.
- Returns:
 - a list of all entries
 
 - 
size
- Returns:
 - the current number of entries in this 
Pool 
 - 
getMaxSize
- Returns:
 - the maximum number of entries in this 
Pool 
 - 
stream
Stream<Pool.Entry<P>> stream()- Returns:
 - a 
Streamover the entries 
 - 
getReservedCount
- Returns:
 - the number of reserved entries
 
 - 
getIdleCount
- Returns:
 - the number of idle entries
 
 - 
getInUseCount
- Returns:
 - the number of in-use entries
 
 - 
getTerminatedCount
- Returns:
 - the number of terminated entries
 
 
 -