SYNOPSIS

#include <buffer.h>

Inherits ost::Mutex, ost::Thread, and ost::Semaphore.

Classes

struct _data

Public Member Functions

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

Create instance of our queue and give it a process priority. virtual ~ThreadQueue ()

Destroy the queue. void setTimer (timeout_t timeout)

Set the queue timeout. void post (const void *data, unsigned len)

Put some unspecified data into this queue.

Protected Types

typedef struct

ost::ThreadQueue::_data data_t"

Protected Member Functions

virtual void final ()

virtual void startQueue (void)

Start of dequeing. virtual void stopQueue (void)

End of dequeing, we expect the queue is empty for now. virtual void onTimer (void)

A derivable method to call when the timout is expired. virtual void runQueue (void *data)=0

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

Protected Attributes

timeout_t timeout

bool started

data_t * first

data_t * last

String name

Additional Inherited Members

Detailed Description

Somewhat generic queue processing class to establish a producer consumer queue.

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.

This class was changed by Angelo Naselli to have a timeout on the queue

in memory data queue interface.

Author:

David Sugar [email protected]

Member Typedef Documentation

typedef struct \fBost::ThreadQueue::_data\fP \fBost::ThreadQueue::data_t\fP\fC [protected]\fP

Constructor & Destructor Documentation

ost::ThreadQueue::ThreadQueue (const char *id, intpri, size_tstack = \fC0\fP)

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

Parameters:

id queue ID.

pri process priority.

stack stack size.

virtual ost::ThreadQueue::~ThreadQueue ()\fC [virtual]\fP

Destroy the queue.

Member Function Documentation

virtual void ost::ThreadQueue::final ()\fC [protected]\fP, \fC [virtual]\fP

Reimplemented from ost::Thread.

virtual void ost::ThreadQueue::onTimer (void)\fC [protected]\fP, \fC [virtual]\fP

A derivable method to call when the timout is expired.

void ost::ThreadQueue::post (const void *data, unsignedlen)

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 ost::ThreadQueue::runQueue (void *data)\fC [protected]\fP, \fC [pure virtual]\fP

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.

void ost::ThreadQueue::setTimer (\fBtimeout_t\fPtimeout)

Set the queue timeout. When the timer expires, the onTimer() method is called for the thread

Parameters:

timeout timeout in milliseconds.

virtual void ost::ThreadQueue::startQueue (void)\fC [protected]\fP, \fC [virtual]\fP

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

virtual void ost::ThreadQueue::stopQueue (void)\fC [protected]\fP, \fC [virtual]\fP

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

\fBdata_t\fP* ost::ThreadQueue::first\fC [protected]\fP

\fBdata_t\fP * ost::ThreadQueue::last\fC [protected]\fP

\fBString\fP ost::ThreadQueue::name\fC [protected]\fP

bool ost::ThreadQueue::started\fC [protected]\fP

\fBtimeout_t\fP ost::ThreadQueue::timeout\fC [protected]\fP

Author

Generated automatically by Doxygen for GNU CommonC++ from the source code.