|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkiwi.util.ResourcePool
An abstract class that represents a pool of instances of some resource.
See TimerPool
for an example concrete implementation. Accesses
to the pool are threadsafe so there is no possibility of contention for
the resource.
Resource
,
TimerPool
Field Summary | |
private java.util.Stack |
availableList
|
private java.util.Stack |
reservedList
|
private int |
size
|
Constructor Summary | |
ResourcePool(int size)
Construct a new ResourcePool of the given size. |
Method Summary | |
protected abstract Resource |
constructResource()
Construct an instance of the resource that is managed by this pool. |
int |
getAvailableResourceCount()
Get the number of resource instances that are currently available. |
int |
getTotalResourceCount()
Get the total number of resource instances in this pool. |
int |
getUsedResourceCount()
Get the number of resource instances that are currently in use. |
void |
releaseResource(Resource resource)
Release the given resource. |
Resource |
reserveResource()
Reserve one instance of the resource. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int size
private java.util.Stack reservedList
private java.util.Stack availableList
Constructor Detail |
public ResourcePool(int size)
ResourcePool
of the given size.
size
- The number of instances of a resource to preallocate in this
pool.Method Detail |
public Resource reserveResource()
Resource
.public void releaseResource(Resource resource)
resource
- The Resource
to release.protected abstract Resource constructResource()
Resource
instance.public int getTotalResourceCount()
public int getUsedResourceCount()
public int getAvailableResourceCount()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |