Rudiments
|
#include <resourcepool.h>
Public Member Functions | |
resourcepool () | |
virtual | ~resourcepool () |
void | setMin (uint64_t min) |
uint64_t | getMin () |
void | setMax (uint64_t max) |
uint64_t | getMax () |
void | setGrowBy (uint64_t growby) |
uint64_t | getGrowBy () |
bool | create () |
bool | clear () |
bool | reset () |
valuetype * | borrowResource () |
bool | returnResource (valuetype *resource) |
void | setMutex (threadmutex *mtx) |
uint64_t | getAvailableInitialResourceCount () |
uint64_t | getAvailableOnDemandResourceCount () |
The resourcepool class provides a pool of objects. Objects can be borrowed from and returned to the pool. The pool contains a configurable number of objects that are allocated when the pool is initialized, and can allocate a configurable number of additional objects on-demand.
|
inline |
Creates an empty instance of the resourcepool class.
|
inlinevirtual |
Deletes this instance of the resourcepool class and all resources in the pool.
|
inline |
Returns a pointer to an instance of "valuetype" from the pool, or NULL if none are available or a mutex lock failed.
|
inline |
Clears the resourcepool, deleting all resources in the pool.
Returns true on success and false if a mutex lock failed.
|
inline |
Creates a resource pool, containing the number of resources configured by setMin().
Returns true on success and false on failure.
|
inline |
Returns the number of resources that are available in the pool without creating any resources on-demand.
|
inline |
Returns the number of resources that have been created on-demand but have not been loaned out.
|
inline |
Returns the number of resources that will be created when the pool grows on-demand.
|
inline |
Returns the number of resources that the pool can grow to on-demand.
|
inline |
Returns the number of resources that will be created when the pool is initialized.
|
inline |
Clears the resourcepool, deleting all resources in the pool, and resets min, max, and growby to defaults.
Returns true on success and false if a mutex lock failed.
|
inline |
Returns "resource" to the pool.
Returns true on success and false if a mutex lock failed.
|
inline |
Sets the number of resources that will be created when the pool grows on-demand.
Defaults to 1.
|
inline |
Sets the maximum number of resources that the pool can grow to on-demand.
Defaults to 10.
|
inline |
Sets the number of resources that will be created when the pool is initialized.
Defaults to 0.
|
inline |
Sets a mutex to use when borrowing or returning resources. To not use a mutex set "mtx" to NULL. Defaults to NULL.