Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

ThreadQueue Class Reference

Somewhat generic queue processing class to establish a producer consumer queue. in memory data queue interface. More...

#include <buffer.h>

Inheritance diagram for ThreadQueue:

Mutex Thread Semaphore List of all members.

Public Member Functions

 ThreadQueue (const char *id, int pri, size_t stack=0)
 Create instance of our queue and give it a process priority.
 ~ThreadQueue ()
 Destroy the queue.
void post (const void *data, unsigned len)
 Put some unspecified data into this queue.

Protected Member Functions

virtual void startQueue (void)
 Start of dequeing.
virtual void stopQueue (void)
 End of dequeing, we expect the queue is empty for now.
virtual void runQueue (void *data)=0
 Virtual callback method to handle processing of a queued data items.

Protected Attributes

const char * name

Detailed Description

Somewhat generic queue processing class to establish a producer consumer queue. in memory data queue interface.

This may be used to buffer cdr records, or for other purposes where an in-memory queue is needed for rapid posting. This class is derived from Mutex and maintains a linked list. A thread is used to dequeue data and pass it to a callback method that is used in place of "run" for each item present on the queue. The conditional is used to signal the run thread when new data is posted.

Author:
David Sugar <dyfet@ostel.com>


Constructor & Destructor Documentation

ThreadQueue::ThreadQueue const char *  id,
int  pri,
size_t  stack = 0
 

Create instance of our queue and give it a process priority.

Parameters:
id queue ID.
pri process priority.
stack stack size.

ThreadQueue::~ThreadQueue  ) 
 

Destroy the queue.


Member Function Documentation

void ThreadQueue::post const void *  data,
unsigned  len
 

Put some unspecified data into this queue.

A new qd structure is created and sized to contain a copy of the actual content.

Parameters:
data pointer to data.
len size of data.

virtual void ThreadQueue::runQueue void *  data  )  [protected, pure virtual]
 

Virtual callback method to handle processing of a queued data items.

After the item is processed, it is deleted from memory. We can call multiple instances of runQueue in order if multiple items are waiting.

Parameters:
data item being dequed.

virtual void ThreadQueue::startQueue void   )  [inline, protected, virtual]
 

Start of dequeing.

Maybe we need to connect a database or something, so we have a virtual...

virtual void ThreadQueue::stopQueue void   )  [inline, protected, virtual]
 

End of dequeing, we expect the queue is empty for now.

Maybe we need to disconnect a database or something, so we have another virtual.


Member Data Documentation

const char* ThreadQueue::name [protected]
 


The documentation for this class was generated from the following file:
Generated on Tue Jan 18 14:32:38 2005 for GNU CommonC++ by  doxygen 1.3.9.1