dmlite  0.6
Public Member Functions | Private Attributes
dmlite::PoolContainer< E > Class Template Reference

Implements a pool of whichever resource. More...

#include <poolcontainer.h>

List of all members.

Public Member Functions

 PoolContainer (PoolElementFactory< E > *factory, int n)
 ~PoolContainer ()
 Destructor.
acquire (bool block=true)
 Acquires a free resource.
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::queue< E > free_
std::map< E, unsigned > used_
unsigned freeSlots_
boost::mutex mutex_
boost::condition_variable available_

Detailed Description

template<class E>
class dmlite::PoolContainer< E >

Implements a pool of whichever resource.


Constructor & Destructor Documentation

template<class E>
dmlite::PoolContainer< E >::PoolContainer ( PoolElementFactory< E > *  factory,
int  n 
) [inline]

Constructor

Parameters:
factoryThe factory to use when spawning a new resource.
nThe number of resources to keep.
template<class E>
dmlite::PoolContainer< E >::~PoolContainer ( ) [inline]

Destructor.


Member Function Documentation

template<class E>
E dmlite::PoolContainer< E >::acquire ( bool  block = true) [inline]

Acquires a free resource.

template<class E>
E dmlite::PoolContainer< E >::acquire ( e) [inline]

Increases the reference count of a resource.

template<class E>
unsigned dmlite::PoolContainer< E >::refCount ( e) [inline]

Count the number of instances.

template<class E>
unsigned dmlite::PoolContainer< E >::release ( e) [inline]

Releases a resource

Parameters:
eThe resource to release.
Returns:
The reference count after releasing.
template<class E>
void dmlite::PoolContainer< E >::resize ( int  ns) [inline]

Change the pool size

Parameters:
nsThe new size.

Member Data Documentation

template<class E>
boost::condition_variable dmlite::PoolContainer< E >::available_ [private]
template<class E>
PoolElementFactory<E>* dmlite::PoolContainer< E >::factory_ [private]
template<class E>
std::queue<E> dmlite::PoolContainer< E >::free_ [private]
template<class E>
unsigned dmlite::PoolContainer< E >::freeSlots_ [private]
template<class E>
int dmlite::PoolContainer< E >::max_ [private]
template<class E>
boost::mutex dmlite::PoolContainer< E >::mutex_ [private]
template<class E>
std::map<E, unsigned> dmlite::PoolContainer< E >::used_ [private]

The documentation for this class was generated from the following file: