Inheritance diagram for atomic_class_pool< T >:
Example: class foo { }; atomic_class_pool<foo> pool; foo* f = new(pool) foo; pool.destroy(f);
Definition at line 122 of file atomic_class_pool.h.
Public Member Functions | |
atomic_class_pool (long nbytes=sizeof(T), long seed=128) | |
Create a pool for class T. | |
void | destroy (T *tptr) |
Destroys an object (by calling its destructor) and returns its memory to the pool. | |
uint | nbytes () |
Return the object size given to the constructor. | |
Friends | |
void * | operator new (size_t, atomic_class_pool< T > &) |
WARNING: When finished, call pool.destroy(t) instead of delete. | |
void | operator delete (void *, atomic_class_pool< T > &) |
Called automatically by the compiler if T's constructor throws (otherwise memory would leak). |
atomic_class_pool< T >::atomic_class_pool | ( | long | nbytes = sizeof(T) , |
|
long | seed = 128 | |||
) | [inline] |
Create a pool for class T.
By default the pool will hand out sizeof(T) bytes at a time; if T is a base class and this pool is to be used with subclasses, nbytes must be set at least as large as the largest class. Oversized allocations will assert().
Definition at line 136 of file atomic_class_pool.h.
void atomic_class_pool< T >::destroy | ( | T * | tptr | ) | [inline] |
Destroys an object (by calling its destructor) and returns its memory to the pool.
Undefined behavior results if the object did not come from this pool.
Definition at line 152 of file atomic_class_pool.h.
References atomic_preallocated_pool::dealloc().
Here is the call graph for this function:
void* operator new | ( | size_t | nbytes, | |
atomic_class_pool< T > & | pool | |||
) | [friend] |
WARNING: When finished, call pool.destroy(t) instead of delete.
use placement-style new with the pool.
usage: T* t = new(pool) T(...)
void operator delete | ( | void * | ptr, | |
atomic_class_pool< T > & | pool | |||
) | [friend] |
Called automatically by the compiler if T's constructor throws (otherwise memory would leak).