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.
|
ObjectProtocol * | operator[] (unsigned pos) |
ObjectProtocol * | peek (unsigned offset=0) |
| Examine an existing object on the stack.
|
ObjectProtocol * | pull (timeout_t timeout=0) |
| Get and remove last object pushed on the stack.
|
bool | push (ObjectProtocol *object, timeout_t timeout=0) |
| Push an object into the stack by it's pointer.
|
bool | remove (ObjectProtocol *object) |
| Remove a specific object pointer for the queue.
|
| stack (mempager *pager=((void *) 0), 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.
|
Protected Attributes |
size_t | limit |
Additional Inherited Members |
static void | gettimeout (timeout_t timeout, struct timespec *hires) |
| Convert a millisecond timeout into use for high resolution conditional timers.
|
static pthread_condattr_t * | initializer (void) |
| Support function for getting conditional attributes for realtime scheduling.
|
Detailed Description
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.
- Author:
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 353 of file containers.h.
Constructor & Destructor Documentation
ucommon::stack::stack |
( |
mempager * |
pager = ((void *) 0) , |
|
|
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.
- Parameters:
-
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. |
ucommon::stack::~stack |
( |
| ) |
|
Destroy queue.
If no pager is used, then frees heap.
Member Function Documentation
static size_t ucommon::stack::count |
( |
stack & |
stack | ) |
|
|
inlinestatic |
Convenience function to get count of objects in the stack.
- Parameters:
-
- Returns:
- number of objects in the stack.
Definition at line 460 of file containers.h.
size_t ucommon::stack::getCount |
( |
void |
| ) |
|
Get number of object points currently in the stack.
- Returns:
- number of objects in stack.
Examine an existing object on the stack.
- Parameters:
-
- Returns:
- object examined.
Reimplemented in ucommon::stackof< T >.
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.
- Parameters:
-
timeout | to wait if empty in milliseconds. |
- Returns:
- object pulled from stack or NULL if empty and timed out.
Reimplemented in ucommon::stackof< T >.
Convenience function pull last object from the stack.
- Parameters:
-
stack | to get from. |
timeout | to wait if empty. |
- Returns:
- last object or NULL if timed out empty.
Definition at line 452 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.
- Parameters:
-
object | to push. |
timeout | to wait if stack is full in milliseconds. |
- Returns:
- true if object pushed, false if stack full and timeout expired.
Convenience function to push object into the stack.
- Parameters:
-
stack | to push into. |
object | to push. |
timeout | to wait if full. |
- Returns:
- true if pusheded, false if timed out while full.
Definition at line 443 of file containers.h.
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.
- Parameters:
-
- Returns:
- true if object was removed, false if not found.
Convenience function to remove an object from the stacl.
- Parameters:
-
stack | to remove object from. |
object | to remove. |
- Returns:
- true if removed, false if not found.
Definition at line 433 of file containers.h.
The documentation for this class was generated from the following file: