casa
$Rev:20696$
|
A stack of re-usable objects. More...
#include <ObjectStack.h>
Public Member Functions | |
~ObjectStack () | |
Destructor. | |
T * | get () |
Get a pointer to an object in the stack. | |
void | put (T *obj) |
Return an object to the stack for re-use. | |
void | clear () |
Decimate the stack by getting rid of all unused elements in it. | |
Bool | empty () |
Test if stack empty. | |
uInt | nelements () const |
return the stack extend (for debugging use and checking mainly) | |
Static Public Member Functions | |
static ObjectStack< T > & | stack () |
Create a singleton stack. | |
Private Member Functions | |
ObjectStack () | |
All ctor and assignment constructors and assignment (not implemented) | |
ObjectStack (const ObjectStack< T > &other) | |
ObjectStack< T > & | operator= (const ObjectStack< T > &other) |
Private Attributes | |
vector< T * > | stack_p |
The Stack. | |
Mutex | mutex_p |
A stack of re-usable objects.
Public interface
An ObjectStack contains a set of pre-allocated Objects of the type T
. The stack is a very simple stack, without the linking/unlinking of a normal Stack implementation. This lightweight implementation was especially designed for use with the AutoDiff classes, but can be used independently. The stack works best with small object sizes, or letter/envelope classes.
The class is fully thread-safe, thus the same object can be used safely in multiple threads.
{ // Get an element (and create stack!) SparseDiff<Double> elem; // Use it elem.value() = 27; // Release it (automatic by dtor on elem) }
To improve the speed for the auto differentiating classes.
Definition at line 93 of file ObjectStack.h.
casa::ObjectStack< T >::~ObjectStack | ( | ) |
Destructor.
casa::ObjectStack< T >::ObjectStack | ( | ) | [inline, private] |
All ctor and assignment constructors and assignment (not implemented)
Definition at line 128 of file ObjectStack.h.
casa::ObjectStack< T >::ObjectStack | ( | const ObjectStack< T > & | other | ) | [private] |
void casa::ObjectStack< T >::clear | ( | ) |
Decimate the stack by getting rid of all unused elements in it.
Bool casa::ObjectStack< T >::empty | ( | ) | [inline] |
Test if stack empty.
Definition at line 114 of file ObjectStack.h.
References casa::ObjectStack< T >::stack_p.
T* casa::ObjectStack< T >::get | ( | ) |
Get a pointer to an object in the stack.
The stack will be extended if no objects left.
uInt casa::ObjectStack< T >::nelements | ( | ) | const [inline] |
return the stack extend (for debugging use and checking mainly)
Definition at line 117 of file ObjectStack.h.
ObjectStack<T>& casa::ObjectStack< T >::operator= | ( | const ObjectStack< T > & | other | ) | [private] |
void casa::ObjectStack< T >::put | ( | T * | obj | ) | [inline] |
Return an object to the stack for re-use.
Definition at line 108 of file ObjectStack.h.
References casa::ObjectStack< T >::stack_p.
static ObjectStack<T>& casa::ObjectStack< T >::stack | ( | ) | [static] |
Create a singleton stack.
Mutex casa::ObjectStack< T >::mutex_p [private] |
Definition at line 123 of file ObjectStack.h.
vector<T*> casa::ObjectStack< T >::stack_p [private] |
The Stack.
Definition at line 117 of file ObjectStack.h.
Referenced by casa::ObjectStack< T >::empty(), and casa::ObjectStack< T >::put().