Class WeakPool<B>
java.lang.Object
org.cojen.tupl.util.WeakPool<B>
Utility for sharing a small set of poolable objects (like buffers) which are weakly
referenced. Only one thread at a time can access pooled objects, but any number of threads
can release pooled objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
An entry which weakly references a pooled object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a new pooled entry which refers to the given object.Returns an available pooled entry if any exist.
-
Constructor Details
-
WeakPool
public WeakPool()
-
-
Method Details
-
tryAccess
Returns an available pooled entry if any exist. If an entry is returned but the pooled object is null, discard the entry and try again. A strong reference to the pooled object must be maintained to ensure that it doesn't vanish too soon.Note: This method can only be called by one thread at a time.
-
newEntry
Create a new pooled entry which refers to the given object. This method is thread-safe.
-