dmlite
0.6
|
Implements a pool of whichever resource. More...
#include <poolcontainer.h>
Public Member Functions | |
PoolContainer (PoolElementFactory< E > *factory, int n) | |
~PoolContainer () | |
Destructor. More... | |
E | acquire (bool block=true) |
Acquires a free resource. More... | |
E | acquire (E e) |
Increases the reference count of a resource. More... | |
unsigned | release (E e) |
unsigned | refCount (E e) |
Count the number of instances. More... | |
void | resize (int ns) |
Private Attributes | |
int | max_ |
PoolElementFactory< E > * | factory_ |
std::deque< E > | free_ |
std::map< E, unsigned > | used_ |
int | freeSlots_ |
boost::mutex | mutex_ |
boost::condition_variable | available_ |
Implements a pool of whichever resource.
|
inline |
Constructor
factory | The factory to use when spawning a new resource. |
n | The number of resources to keep in the pool. Up to 10*n slots can be created without penalty (but only n will be pooled) |
|
inline |
Destructor.
|
inline |
Acquires a free resource.
|
inline |
Increases the reference count of a resource.
|
inline |
Count the number of instances.
|
inline |
Releases a resource
e | The resource to release. |
|
inline |
Change the pool size
ns | The new size. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |