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