Package io.deephaven.util.pool
Class ThreadSafeLenientFixedSizePool<T>
java.lang.Object
io.deephaven.util.pool.ThreadSafeLenientFixedSizePool<T>
- All Implemented Interfaces:
Pool<T>
,Pool.MultiGiver<T>
,Pool.MultiPool<T>
,Pool.MultiTaker<T>
,Pool.SinglePool<T>
,PoolEx<T>
public class ThreadSafeLenientFixedSizePool<T>
extends Object
implements Pool.MultiPool<T>, PoolEx<T>
A pool that
- holds at least
size
items, - creates
size
items in the pool immediately, - creates a new item when the pool underflows,
- discards the item when the pool overflows,
- optionally clears the items given to it, and
- IS thread-safe
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.base.pool.Pool
Pool.Factory, Pool.MultiGiver<T>, Pool.MultiPool<T>, Pool.MultiTaker<T>, Pool.SinglePool<T>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionThreadSafeLenientFixedSizePool
(String name, int size, Function<ThreadSafeLenientFixedSizePool<T>, T> initFactory, Function<ThreadSafeLenientFixedSizePool<T>, T> overflowFactory, Consumer<? super T> clearingProcedure) ThreadSafeLenientFixedSizePool
(String name, int size, Supplier<T> initFactory, Supplier<T> overflowFactory, Consumer<? super T> clearingProcedure) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Gives an unused item back to the pool.protected boolean
giveInternal
(T item) take()
Takes an item from the pool.Deprecated.tryTake()
Take an item if immediately available, else return null.
-
Field Details
-
MIN_SIZE
public static final int MIN_SIZE- See Also:
-
-
Constructor Details
-
ThreadSafeLenientFixedSizePool
-
ThreadSafeLenientFixedSizePool
-
-
Method Details
-
take
Description copied from interface:Pool
Takes an item from the pool. Depending on pool policy, if there are no items available, this may block, create a new item, or throw aPoolEmptyException
. -
give
Description copied from interface:Pool
Gives an unused item back to the pool. Passingnull
is safe and has no effect. If the pool has a clearing procedure, the item will be cleared. Depending on pool policy, if the pool is full, this may block, discard the item, or throw aPoolFullException
. -
giveInternal
-
takeMaybeNull
Deprecated. -
tryTake
Description copied from interface:PoolEx
Take an item if immediately available, else return null.
-