$search
A fixed-count lock-free pool of the same type of object. Supports both bare- and shared-pointer allocation. More...
#include <object_pool.h>
Classes | |
struct | Deleter |
Public Member Functions | |
T * | allocate () |
Allocate a single object from the pool, returning a bare pointer. | |
boost::shared_ptr< T > | allocateShared () |
Allocate a single object from the pool, returning a shared pointer. | |
void | free (T const *t) |
Return an object allocated through allocateBare() to the pool. | |
bool | hasOutstandingAllocations () |
Returns whether or not this ObjectPool has any outstanding allocations. | |
void | initialize (uint32_t count, const T &tmpl) |
initialize the pool. Only use with the default constructor | |
boost::shared_ptr< T const > | makeShared (T const *t) |
Make a shared_ptr out of a bare pointer allocated by this pool. | |
boost::shared_ptr< T > | makeShared (T *t) |
Make a shared_ptr out of a bare pointer allocated by this pool. | |
ObjectPool (uint32_t count, const T &tmpl) | |
Constructor with initialization. | |
ObjectPool () | |
Default constructor. Must call initialize() before calling allocate(). | |
bool | owns (const boost::shared_ptr< T const > &t) |
Returns whether or not this pool owns the provided object. | |
bool | owns (T const *t) |
Returns whether or not this pool owns the provided object. | |
T const * | removeShared (const boost::shared_ptr< T const > &t) |
"Remove" a shared pointer allocated by this pool, turning it into a bare pointer. shared_ptrs held to this object will no longer delete the object when the go out of scope. Generally dangerous and not to be used lightly, this will probably go away in the future. | |
T * | removeShared (const boost::shared_ptr< T > &t) |
"Remove" a shared pointer allocated by this pool, turning it into a bare pointer. shared_ptrs held to this object will no longer delete the object when the go out of scope. Generally dangerous and not to be used lightly, this will probably go away in the future. | |
~ObjectPool () | |
Private Member Functions | |
template<typename T2 > | |
boost::shared_ptr< T2 > | makeSharedImpl (T2 *t) |
Private Attributes | |
FreeList | freelist_ |
bool | initialized_ |
FreeList | sp_storage_freelist_ |
A fixed-count lock-free pool of the same type of object. Supports both bare- and shared-pointer allocation.
T | the object type |
Definition at line 192 of file object_pool.h.
lockfree::ObjectPool< T >::ObjectPool | ( | ) | [inline] |
Default constructor. Must call initialize() before calling allocate().
Definition at line 222 of file object_pool.h.
lockfree::ObjectPool< T >::ObjectPool | ( | uint32_t | count, | |
const T & | tmpl | |||
) | [inline] |
Constructor with initialization.
count | The number of objects in the pool | |
tmpl | The object template to use to construct the objects |
Definition at line 232 of file object_pool.h.
lockfree::ObjectPool< T >::~ObjectPool | ( | ) | [inline] |
Definition at line 238 of file object_pool.h.
T* lockfree::ObjectPool< T >::allocate | ( | ) | [inline] |
Allocate a single object from the pool, returning a bare pointer.
Definition at line 341 of file object_pool.h.
boost::shared_ptr<T> lockfree::ObjectPool< T >::allocateShared | ( | ) | [inline] |
Allocate a single object from the pool, returning a shared pointer.
Definition at line 272 of file object_pool.h.
void lockfree::ObjectPool< T >::free | ( | T const * | t | ) | [inline] |
Return an object allocated through allocateBare() to the pool.
t | An object that was allocated with allocateBare() |
Definition at line 350 of file object_pool.h.
bool lockfree::ObjectPool< T >::hasOutstandingAllocations | ( | ) | [inline] |
Returns whether or not this ObjectPool has any outstanding allocations.
Definition at line 247 of file object_pool.h.
void lockfree::ObjectPool< T >::initialize | ( | uint32_t | count, | |
const T & | tmpl | |||
) | [inline] |
initialize the pool. Only use with the default constructor
count | The number of objects in the pool | |
tmpl | The object template to use to construct the objects |
Definition at line 257 of file object_pool.h.
boost::shared_ptr<T const> lockfree::ObjectPool< T >::makeShared | ( | T const * | t | ) | [inline] |
Make a shared_ptr out of a bare pointer allocated by this pool.
Definition at line 303 of file object_pool.h.
boost::shared_ptr<T> lockfree::ObjectPool< T >::makeShared | ( | T * | t | ) | [inline] |
Make a shared_ptr out of a bare pointer allocated by this pool.
Definition at line 295 of file object_pool.h.
boost::shared_ptr<T2> lockfree::ObjectPool< T >::makeSharedImpl | ( | T2 * | t | ) | [inline, private] |
Definition at line 374 of file object_pool.h.
bool lockfree::ObjectPool< T >::owns | ( | const boost::shared_ptr< T const > & | t | ) | [inline] |
Returns whether or not this pool owns the provided object.
Definition at line 366 of file object_pool.h.
bool lockfree::ObjectPool< T >::owns | ( | T const * | t | ) | [inline] |
Returns whether or not this pool owns the provided object.
Definition at line 358 of file object_pool.h.
T const* lockfree::ObjectPool< T >::removeShared | ( | const boost::shared_ptr< T const > & | t | ) | [inline] |
"Remove" a shared pointer allocated by this pool, turning it into a bare pointer. shared_ptrs held to this object will no longer delete the object when the go out of scope. Generally dangerous and not to be used lightly, this will probably go away in the future.
Definition at line 327 of file object_pool.h.
T* lockfree::ObjectPool< T >::removeShared | ( | const boost::shared_ptr< T > & | t | ) | [inline] |
"Remove" a shared pointer allocated by this pool, turning it into a bare pointer. shared_ptrs held to this object will no longer delete the object when the go out of scope. Generally dangerous and not to be used lightly, this will probably go away in the future.
Definition at line 313 of file object_pool.h.
FreeList lockfree::ObjectPool< T >::freelist_ [private] |
Definition at line 391 of file object_pool.h.
bool lockfree::ObjectPool< T >::initialized_ [private] |
Definition at line 389 of file object_pool.h.
FreeList lockfree::ObjectPool< T >::sp_storage_freelist_ [private] |
Definition at line 392 of file object_pool.h.