|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcreamtec.core.util.ResourcePool
public class ResourcePool
Constructor Summary | |
---|---|
ResourcePool(ResourceFactory factory,
int maxSize)
|
|
ResourcePool(ResourceFactory factory,
int initSize,
int maxSize,
int maxFree)
Manages a pool of resources. |
Method Summary | |
---|---|
void |
clear()
Frees all allocated resources |
int |
getAllocatedResourceCount()
Returns the total number of created resources, in and out of the pool |
int |
getAvailableResourceCount()
Returns the number of resources currently available in the pool |
int |
getMaxSize()
Returns the maximum number of resources allowed |
java.lang.String |
getName()
|
java.lang.Object |
getResource()
Obtains a resource from the pool if there is one available. |
void |
putResource(java.lang.Object resource)
Returns the resource to the pool. |
void |
setName(java.lang.String name)
Sets pool name that will be used in tracing |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourcePool(ResourceFactory factory, int maxSize) throws java.lang.Exception
java.lang.Exception
public ResourcePool(ResourceFactory factory, int initSize, int maxSize, int maxFree) throws java.lang.Exception
factory
- Factory responsible for creating and freeing of resourcesinitSize
- Initial size of the pool. initSize resources will be pre-created when the pool is createdmaxSize
- Maximum size of the pool. No more then maxSize resources can be createdmaxFree
- Maximum number of free resources to keep in the pool. When maxFree resources are available
in the pool and another resource is returned, it will be freed using the Factory rather then pooled
java.lang.Exception
Method Detail |
---|
public java.lang.Object getResource() throws java.lang.Exception
java.lang.Exception
public void putResource(java.lang.Object resource) throws java.lang.Exception
java.lang.Exception
public int getAvailableResourceCount()
public int getAllocatedResourceCount()
public int getMaxSize()
public void clear() throws java.lang.Exception
java.lang.Exception
public void setName(java.lang.String name)
public java.lang.String getName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |