Free Electron
|
Pool of Counted elements. More...
#include <CountedPool.h>
Public Member Functions | |
sp< Counted > | get (void) |
Pool of Counted elements.
The templated type needs to provide a reset(void) method to facilitate reuse of objects (when they are only referenced by this container).
The class is designed to be declared mutable and as such still be functional as a member of a const object. Objects of this class are non-locking thread-safe by the use of thread specific pointers. Each thread accesses an independant pool.
If thread specific pointers are not deemed available or reliable, this object may devolve to simple new() allocation. For example, boost::thread_specific_ptr can throw thread_resource_error if threading is not in use. This is caught by CountedPool which will degenerate into no pooling.