ucommon
|
Manage a thread-safe stack of objects through reference pointers. More...
#include <containers.h>
Public Member Functions | |
size_t | getCount (void) |
Get number of object points currently in the stack. | |
Object * | pull (timeout_t timeout=0) |
Get and remove last object pushed on the stack. | |
bool | push (Object *object, timeout_t timeout=0) |
Push an object into the stack by it's pointer. | |
bool | remove (Object *object) |
Remove a specific object pointer for the queue. | |
stack (mempager *pager=NULL, size_t number=0) | |
Create a stack that uses a memory pager for internally managed member objects for a specified maximum number of object pointers. | |
~stack () | |
Destroy queue. | |
Static Public Member Functions | |
static size_t | count (stack &stack) |
Convenience function to get count of objects in the stack. | |
static Object * | pull (stack &stack, timeout_t timeout=0) |
Convenience function pull last object from the stack. | |
static bool | push (stack &stack, Object *object, timeout_t timeout=0) |
Convenience function to push object into the stack. | |
static bool | remove (stack &stack, Object *object) |
Convenience function to remove an object from the stacl. | |
Protected Attributes | |
size_t | limit |
Friends | |
class | member |
Manage a thread-safe stack of objects through reference pointers.
This Thread-safe access is managed through a conditional. This differs from the queue in lifo mode because delinking the last object is immediate, and because it has much less overhead. A pool of self-managed member objects are used to operate the stack.
Definition at line 334 of file containers.h.
stack::stack | ( | mempager * | pager = NULL , |
size_t | number = 0 |
||
) |
Create a stack that uses a memory pager for internally managed member objects for a specified maximum number of object pointers.
pager | to use for internal member object or NULL to use heap. |
number | of pointers that can be in the stack or 0 if unlimited. |
stack::~stack | ( | ) |
Destroy queue.
If no pager is used, then frees heap.
static size_t stack::count | ( | stack & | stack | ) | [inline, static] |
Convenience function to get count of objects in the stack.
stack | to count. |
Definition at line 434 of file containers.h.
size_t stack::getCount | ( | void | ) |
Get number of object points currently in the stack.
Get and remove last object pushed on 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 in stackof< T >.
Convenience function pull last object from the stack.
stack | to get from. |
timeout | to wait if empty. |
Definition at line 426 of file containers.h.
Push an object into the stack by it's pointer.
This can wait for a specified timeout if the stack is full, for example, for another thread to remove an object pointer. This also retains the object.
object | to push. |
timeout | to wait if stack is full in milliseconds. |
Convenience function to push object into the stack.
stack | to push into. |
object | to push. |
timeout | to wait if full. |
Definition at line 417 of file containers.h.
bool stack::remove | ( | Object * | object | ) |
Remove a specific object pointer for the queue.
This can remove a member from any location in the queue, whether beginning, end, or somewhere in the middle. This also releases the object.
object | to remove. |
Convenience function to remove an object from the stacl.
stack | to remove object from. |
object | to remove. |
Definition at line 407 of file containers.h.