Package com.yahoo.yolean.concurrent
Class ConcurrentResourcePool<T>
java.lang.Object
com.yahoo.yolean.concurrent.ConcurrentResourcePool<T>
- All Implemented Interfaces:
Iterable<T>
A pool of a resource. This create new instances of the resource on request until enough are created
to deliver a unique one to all threads needing one concurrently and then reuse those instances
in subsequent requests.
- Author:
- baldersheim
-
Constructor Details
-
ConcurrentResourcePool
-
-
Method Details
-
preallocate
public void preallocate(int instances) -
alloc
Allocates an instance of the resource to the requestor. The resource will be allocated exclusively to the requestor until it calls free(instance).- Returns:
- a reused or newly created instance of the resource
-
free
Frees an instance previously acquired bty alloc -
iterator
-