Go to the documentation of this file.
35 #ifndef LOCKFREE_OBJECT_POOL_H
36 #define LOCKFREE_OBJECT_POOL_H
42 #include <boost/shared_ptr.hpp>
58 template<
class T>
class SPAllocator;
62 class SPAllocator<void>
73 typedef SPAllocator<U>
other;
76 SPAllocator(FreeList* pool, SPStorage* block)
throw ()
131 pool_ = u.get_pool();
152 uint32_t to_alloc = n *
sizeof(T);
161 uint32_t to_free = n *
sizeof(T);
263 void initialize(uint32_t count,
const T& tmpl)
267 freelist_.template constructAll<T>(tmpl);
311 return makeSharedImpl<T const>(t);
323 Deleter*
d = boost::get_deleter<Deleter>(t);
337 Deleter*
d = boost::get_deleter<Deleter>(t);
356 void free(T
const* t)
364 bool owns(T
const* t)
374 return owns(t.get());
379 template<
typename T2>
403 #endif // LOCKFREE_OBJECT_POOL_H
FreeList * get_pool() const
Deleter(ObjectPool *pool, detail::SPStorage *storage)
void free(void const *mem)
Free a block of memory allocated from this FreeList.
ptrdiff_t difference_type
boost::shared_ptr< T2 > makeSharedImpl(T2 *t)
void construct(pointer p, const_reference val)
A fixed-count lock-free pool of the same type of object. Supports both bare- and shared-pointer alloc...
FreeList sp_storage_freelist_
bool owns(void const *mem)
Returns whether or not this FreeList owns a block of memory.
pointer allocate(size_type n, SPAllocator< void >::const_pointer hint=0)
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...
void initialize(uint32_t block_size, uint32_t block_count)
Initialize this FreeList. Only use if you used to default constructor.
bool hasOutstandingAllocations()
Returns whether or not this ObjectPool has any outstanding allocations.
T * allocate()
Allocate a single object from the pool, returning a bare pointer.
const typedef T & const_reference
size_type max_size() const
void operator()(T const *t)
#define ROS_ASSERT_MSG(cond,...)
void deallocate(pointer p, size_type n)
boost::shared_ptr< T > allocateShared()
Allocate a single object from the pool, returning a shared pointer.
SPStorage * get_block() const
bool owns(T const *t)
Returns whether or not this pool owns the provided object.
const typedef T * const_pointer
boost::shared_ptr< T > makeShared(T *t)
Make a shared_ptr out of a bare pointer allocated by this pool.
void free(T const *t)
Return an object allocated through allocateBare() to the pool.
void * allocate()
Allocate a single block from this FreeList.
void initialize(uint32_t count, const T &tmpl)
initialize the pool. Only use with the default constructor
A lock-free (not wait-free) statically-sized free-list implemented with CAS.
SPAllocator(FreeList *pool, SPStorage *block)
pointer address(reference r) const
bool hasOutstandingAllocations()
Returns whether or not this FreeList currently has any outstanding allocations.
ObjectPool()
Default constructor. Must call initialize() before calling allocate()
lockfree
Author(s): Josh Faust
autogenerated on Wed Mar 2 2022 00:54:15