UCommon
|
A templated typed class for thread-safe stack of object pointers. More...
#include <containers.h>
Public Member Functions | |
const T & | at (unsigned offset=0) |
Examine past item in the stack. | |
T * | operator() (unsigned offset=0) |
const T & | operator[] (unsigned offset) |
Examine past item in the stack. | |
const T * | peek (timeout_t timeout=0) |
Examine last typed object posted to the stack. | |
T * | pull (timeout_t timeout=0) |
Get and remove last typed object posted to the stack. | |
bool | push (T *object, timeout_t timeout=0) |
Push a typed object into the stack by it's pointer. | |
bool | remove (T *object) |
Remove a specific typed object pointer for the stack. | |
stackof (mempager *memory, size_t size=0) | |
Create templated stack of typed objects. |
A templated typed class for thread-safe stack of object pointers.
This allows one to use the stack class in a typesafe manner for a specific object type derived from Object rather than generically for any derived object class.
Definition at line 525 of file containers.h.
ucommon::stackof< T >::stackof | ( | mempager * | memory, |
size_t | size = 0 |
||
) | [inline] |
Create templated stack of typed objects.
memory | pool for internal use of stack. |
size | of stack to construct. Uses 0 if no size limit. |
Definition at line 533 of file containers.h.
const T& ucommon::stackof< T >::at | ( | unsigned | offset = 0 | ) | [inline] |
Examine past item in the stack.
This is a typecast of the peek operation.
offset | in stack. |
Definition at line 584 of file containers.h.
const T& ucommon::stackof< T >::operator[] | ( | unsigned | offset | ) | [inline] |
Examine past item in the stack.
This is a typecast of the peek operation.
offset | in stack. |
Definition at line 593 of file containers.h.
const T* ucommon::stackof< T >::peek | ( | timeout_t | timeout = 0 | ) | [inline] |
Examine last typed object posted to the stack.
This can wait for a specified timeout of the stack is empty.
timeout | to wait if empty in milliseconds. |
Reimplemented from ucommon::Stack.
Definition at line 572 of file containers.h.
T* ucommon::stackof< T >::pull | ( | timeout_t | timeout = 0 | ) | [inline] |
Get and remove last typed object posted to the stack.
This can wait for a specified timeout of the stack is empty. The object is still retained and must be released or deleted by the receiving function.
timeout | to wait if empty in milliseconds. |
Reimplemented from ucommon::Stack.
Definition at line 563 of file containers.h.
bool ucommon::stackof< T >::push | ( | T * | object, |
timeout_t | timeout = 0 |
||
) | [inline] |
Push a typed object into the stack by it's pointer.
This can wait for a specified timeout if the queue is full, for example, for another thread to remove an object pointer. This retains the object.
object | to push. |
timeout | to wait if queue is full in milliseconds. |
Definition at line 553 of file containers.h.
bool ucommon::stackof< T >::remove | ( | T * | object | ) | [inline] |
Remove a specific typed object pointer for the stack.
This can remove a member from any location in the stack, whether beginning, end, or somewhere in the middle. This releases the object.
object | to remove. |
Definition at line 542 of file containers.h.