java.lang.Object
org.cojen.tupl.util.LocalPool<B>
Utility for sharing a small set of poolable objects (like buffers) which have thread
affinity. A thread should only request a single object from the pool to prevent deadlocks.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
LocalPool
Construct a pool with a maximum size equal to the number of available processors.- Parameters:
supplier
- can pass null to create entries which initially reference null
-
LocalPool
Construct a pool with the given maximum size. If negative, then this is multiplied by the number of available processors and negated.- Parameters:
supplier
- can pass null to create entries which initially reference null
-
-
Method Details
-
access
Returns an available pooled object, blocking if necessary. -
clear
Removes all pooled objects and passes them to the optional consumer for cleanup. Calling this method doesn't prevent new pooled objects from being created concurrently by the original supplier.
-