ucommon
Public Member Functions
ucommon::queueof< T > Class Template Reference

A templated typed class for thread-safe queue of object pointers. More...

#include <containers.h>

Inheritance diagram for ucommon::queueof< T >:
Inheritance graph
[legend]
Collaboration diagram for ucommon::queueof< T >:
Collaboration graph
[legend]

Public Member Functions

const T & at (unsigned offset=0)
 Examine past item in the queue. More...
 
T * fifo (timeout_t timeout=0)
 Get and remove first typed object posted to the queue. More...
 
T * lifo (timeout_t timeout=0)
 Get and remove last typed object posted to the queue. More...
 
T * operator() (unsigned offset=0)
 
T & operator[] (unsigned offset)
 Examine past item in the queue. More...
 
bool post (T *object, timeout_t timeout=0)
 Post a typed object into the queue by it's pointer. More...
 
 queueof (mempager *memory, size_t size=0)
 Create templated queue of typed objects. More...
 
bool remove (T *object)
 Remove a specific typed object pointer for the queue. More...
 
- Public Member Functions inherited from ucommon::Queue
size_t count (void) const
 Get number of object points currently in the queue. More...
 
ObjectProtocolfifo (timeout_t timeout=0)
 Get and remove last object posted to the queue. More...
 
ObjectProtocolget (unsigned offset=0)
 Examine pending existing object in queue. More...
 
ObjectProtocollifo (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...
 

Additional Inherited Members

- Protected Member Functions inherited from ucommon::Queue
virtual ObjectProtocolinvalid (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...
 
LinkedObjectbegin (void) const
 Return first object in list for iterators. More...
 
unsigned count (void) const
 Count of objects this list manages. More...
 
LinkedObjectend (void) const
 Return last object in list for iterators. More...
 
LinkedObjectfind (unsigned offset) const
 Find a specific member in the ordered list. More...
 
LinkedObjectget (void)
 Get (pull) object off the list. More...
 
LinkedObjectgetIndexed (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...
 
LinkedObjectoperator* () const
 Return head object pointer. More...
 
void operator*= (OrderedObject *object)
 Add object to our list. More...
 
OrderedIndexoperator= (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.
 
- 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...
 
- Protected Attributes inherited from ucommon::Queue
size_t limit
 
- Protected Attributes inherited from ucommon::OrderedIndex
OrderedObjecthead
 
OrderedObjecttail
 

Detailed Description

template<class T>
class ucommon::queueof< T >

A templated typed class for thread-safe queue of object pointers.

This allows one to use the queue class in a typesafe manner for a specific object type derived from Object rather than generically for any derived object class.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Examples:
queue.cpp.

Definition at line 605 of file containers.h.

Constructor & Destructor Documentation

template<class T>
ucommon::queueof< T >::queueof ( mempager memory,
size_t  size = 0 
)
inline

Create templated queue of typed objects.

Parameters
memorypool for internal use by queue.
sizeof queue to construct. Uses 0 if no size limit.

Definition at line 613 of file containers.h.

Member Function Documentation

template<class T>
const T& ucommon::queueof< T >::at ( unsigned  offset = 0)
inline

Examine past item in the queue.

This is a typecast of the peek operation.

Parameters
offsetin queue.
Returns
item pointer if valid or NULL.

Definition at line 662 of file containers.h.

Here is the call graph for this function:

template<class T>
T* ucommon::queueof< T >::fifo ( timeout_t  timeout = 0)
inline

Get and remove first typed object posted to the queue.

This can wait for a specified timeut of the queue is empty. The object is still retained and must be released or deleted by the receiving function.

Parameters
timeoutto wait if empty in milliseconds.
Returns
object from queue or NULL if empty and timed out.

Definition at line 643 of file containers.h.

Here is the call graph for this function:

template<class T>
T* ucommon::queueof< T >::lifo ( timeout_t  timeout = 0)
inline

Get and remove last typed 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.

Parameters
timeoutto wait if empty in milliseconds.
Returns
object from queue or NULL if empty and timed out.

Definition at line 653 of file containers.h.

Here is the call graph for this function:

template<class T>
T& ucommon::queueof< T >::operator[] ( unsigned  offset)
inline

Examine past item in the queue.

This is a typecast of the peek operation.

Parameters
offsetin queue.
Returns
item pointer if valid or NULL.

Definition at line 671 of file containers.h.

Here is the call graph for this function:

template<class T>
bool ucommon::queueof< T >::post ( T *  object,
timeout_t  timeout = 0 
)
inline

Post a typed 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 retains the object.

Parameters
objectto post.
timeoutto wait if queue is full in milliseconds.
Returns
true if object posted, false if queue full and timeout expired.

Definition at line 633 of file containers.h.

Here is the call graph for this function:

template<class T>
bool ucommon::queueof< T >::remove ( T *  object)
inline

Remove a specific typed 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 releases the object.

Parameters
objectto remove.
Returns
true if object was removed, false if not found.

Definition at line 622 of file containers.h.

Here is the call graph for this function:


The documentation for this class was generated from the following file: