|
UCommon
|
Manage a thread-safe queue of objects through reference pointers. More...
#include <containers.h>


Public Member Functions | |
| size_t | count (void) |
| Get number of object points currently in the queue. More... | |
| ObjectProtocol * | fifo (timeout_t timeout=0) |
| Get and remove last object posted to the queue. More... | |
| ObjectProtocol * | get (unsigned offset=0) |
| Examine pending existing object in queue. More... | |
| ObjectProtocol * | lifo (timeout_t timeout=0) |
| Get and remove first object posted to the queue. More... | |
| bool | post (ObjectProtocol *object, timeout_t timeout=0) |
| Post an object into the queue by it's pointer. More... | |
| Queue (mempager *pager=((void *) 0), size_t number=0) | |
| Create a queue that uses a memory pager for internally managed member objects for a specified maximum number of object pointers. More... | |
| bool | remove (ObjectProtocol *object) |
| Remove a specific object pointer for the queue. More... | |
| ~Queue () | |
| Destroy queue. More... | |
Protected Member Functions | |
| virtual ObjectProtocol * | invalid (void) const |
Protected Member Functions inherited from ucommon::OrderedIndex | |
| void | copy (const OrderedIndex &source) |
| void | add (OrderedObject *ordered) |
| Add an object into the ordered index. More... | |
| LinkedObject * | begin (void) const |
| Return first object in list for iterators. More... | |
| unsigned | count (void) const |
| Count of objects this list manages. More... | |
| LinkedObject * | end (void) const |
| Return last object in list for iterators. More... | |
| LinkedObject * | find (unsigned offset) const |
| Find a specific member in the ordered list. More... | |
| LinkedObject * | get (void) |
| Get (pull) object off the list. More... | |
| LinkedObject * | getIndexed (unsigned index) const |
| Get an indexed member from the ordered index. More... | |
| LinkedObject ** | index (void) const |
| Return a pointer to the head of the list. More... | |
| virtual void | lock_index (void) |
| Used to synchronize lists managed by multiple threads. More... | |
| LinkedObject * | operator* () const |
| Return head object pointer. More... | |
| void | operator*= (OrderedObject *object) |
| Add object to our list. More... | |
| OrderedIndex & | operator= (const OrderedIndex &object) |
| Assign ordered index. More... | |
| OrderedIndex () | |
| Create and initialize an empty index. | |
| OrderedIndex (const OrderedIndex &source) | |
| void | purge (void) |
| Purge the linked list and then set the index to empty. | |
| void | reset (void) |
| Reset linked list to empty without purging. | |
| virtual void | unlock_index (void) |
| Used to synchronize lists managed by multiple threads. More... | |
| virtual | ~OrderedIndex () |
| Destroy index. | |
Protected Member Functions inherited from ucommon::Conditional | |
| 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. | |
Protected Attributes | |
| size_t | limit |
Protected Attributes inherited from ucommon::OrderedIndex | |
| OrderedObject * | head |
| OrderedObject * | tail |
Friends | |
| class | member |
Additional Inherited Members | |
Static Protected Member Functions inherited from ucommon::Conditional | |
| 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 queue of objects through reference pointers.
This can be particularly interesting when used to enqueue/dequeue reference counted managed objects. Thread-safe access is managed through a conditional. Both lifo and fifo forms of queue access may be used. A pool of self-managed member objects are used to operate the queue. This queue is optimized for fifo access; while lifo is supported, it will be slow. If you need primarily lifo, you should use stack instead.
Definition at line 215 of file containers.h.
| ucommon::Queue::Queue | ( | mempager * | pager = ((void *) 0), |
| size_t | number = 0 |
||
| ) |
Create a queue 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 queue or 0 for unlimited. size limit. |
| ucommon::Queue::~Queue | ( | ) |
Destroy queue.
If no mempager is used, then frees heap.
| size_t ucommon::Queue::count | ( | void | ) |
Get number of object points currently in the queue.
| ObjectProtocol* ucommon::Queue::fifo | ( | timeout_t | timeout = 0 | ) |
Get and remove last object posted to the queue.
This can wait for a specified timeout of the queue is empty. The object is still retained and must be released or deleted by the receiving function.
| timeout | to wait if empty in milliseconds. |
| ObjectProtocol* ucommon::Queue::get | ( | unsigned | offset = 0 | ) |
Examine pending existing object in queue.
Does not remove it.
| number | of elements back. |
| ObjectProtocol* ucommon::Queue::lifo | ( | timeout_t | timeout = 0 | ) |
Get and remove first object posted to the queue.
This can wait for a specified timeout of the queue is empty. The object is still retained and must be released or deleted by the receiving function.
| timeout | to wait if empty in milliseconds. |
| bool ucommon::Queue::post | ( | ObjectProtocol * | object, |
| timeout_t | timeout = 0 |
||
| ) |
Post an object into the queue 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 also retains the object.
| object | to post. |
| timeout | to wait if queue is full in milliseconds. |
| bool ucommon::Queue::remove | ( | ObjectProtocol * | 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. |
1.8.6