Manage a thread-safe stack of objects through reference pointers.
More...
#include <containers.h>
|
virtual ObjectProtocol * | invalid (void) const |
|
void | broadcast (void) |
| Signal the conditional to release all waiting threads.
|
|
| Conditional () |
| Initialize and construct conditional.
|
|
void | lock (void) |
| Lock the conditional's supporting mutex.
|
|
void | signal (void) |
| Signal the conditional to release one waiting thread.
|
|
void | unlock (void) |
| Unlock the conditional's supporting mutex.
|
|
bool | wait (timeout_t timeout) |
| Conditional wait for signal on millisecond timeout. More...
|
|
bool | wait (struct timespec *timeout) |
| Conditional wait for signal on timespec timeout. More...
|
|
void | wait (void) |
| Wait (block) until signalled.
|
|
| ~Conditional () |
| Destroy conditional, release any blocked threads.
|
|
|
static pthread_condattr_t * | initializer (void) |
| Support function for getting conditional attributes for realtime scheduling. More...
|
|
static void | set (struct timespec *hires, timeout_t timeout) |
| Convert a millisecond timeout into use for high resolution conditional timers. More...
|
|
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 310 of file containers.h.
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. |
virtual ucommon::Stack::~Stack |
( |
| ) |
|
|
virtual |
Destroy queue.
If no pager is used, then frees heap.
size_t ucommon::Stack::count |
( |
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.
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.
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.
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.
The documentation for this class was generated from the following file: