Yate
Public Member Functions | Protected Member Functions | Friends | List of all members
MessageQueue Class Reference

A message queue. More...

#include <yatengine.h>

Inheritance diagram for MessageQueue:
MessageHook Mutex RefObject Lockable GenObject

Public Member Functions

 MessageQueue (const char *hookName, int numWorkers=0)
 
 ~MessageQueue ()
 
virtual bool enqueue (Message *msg)
 
bool dequeue ()
 
void addFilter (const char *name, const char *value)
 
void removeFilter (const String &name)
 
virtual void clear ()
 
void removeThread (Thread *thread)
 
unsigned int count () const
 
const NamedListgetFilters () const
 
virtual bool matchesFilter (const Message &msg)
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual void * getObject (const String &name) const
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual const StringtoString () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- Public Member Functions inherited from Mutex
 Mutex (bool recursive=false, const char *name=0)
 
 Mutex (const Mutex &original)
 
 ~Mutex ()
 
Mutexoperator= (const Mutex &original)
 
virtual bool lock (long maxwait=-1)
 
virtual bool unlock ()
 
virtual bool locked () const
 
const char * owner () const
 
bool recursive () const
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 
virtual bool check (long maxwait=-1)
 
virtual bool unlockAll ()
 

Protected Member Functions

virtual void received (Message &msg)
 
- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 

Friends

class Engine
 

Additional Inherited Members

- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 
- Static Public Member Functions inherited from Mutex
static int count ()
 
static int locks ()
 
static bool efficientTimedLock ()
 
- Static Public Member Functions inherited from Lockable
static void wait (unsigned long maxwait)
 
static unsigned long wait ()
 
static void startUsingNow ()
 
static void enableSafety (bool safe=true)
 
static bool safety ()
 

Detailed Description

A message queue.

MessageQueue class allows to create a private queue for a message who matches the specified filters.

Constructor & Destructor Documentation

MessageQueue ( const char *  hookName,
int  numWorkers = 0 
)

Creates a new message queue.

Parameters
hookNameName of the message served by this queue
numWorkersThe number of workers who serve this queue

Destroys the message queue

Member Function Documentation

void addFilter ( const char *  name,
const char *  value 
)

Add a new filter to this queue

Parameters
nameThe filter name
valueThe filter value
virtual void clear ( )
virtual

Clear private data

Implements MessageHook.

unsigned int count ( ) const
inline

Helper method to obtain the number of unprocessed messages in the queue

Returns
The number of queued messages.
bool dequeue ( )

Process a message from the waiting queue

Returns
False if the message queue is empty
virtual bool enqueue ( Message msg)
virtual

Append a message in the queue

Parameters
msgThe message to enqueue, will be destroyed after the processing is done
Returns
True if successfully queued, false otherwise

Implements MessageHook.

const NamedList& getFilters ( ) const
inline

Obtain the filter list for this queue

Returns
The filter list
virtual bool matchesFilter ( const Message msg)
virtual

Check if the given message can be inserted in this queue

Parameters
msgThe message to check
Returns
True if the message can be inserted in this queue

Implements MessageHook.

virtual void received ( Message msg)
protectedvirtual

Callback method for message processing Default calls Engine::dispatch

Parameters
msgThe message to process
void removeFilter ( const String name)

Remove a filter form this queue

Parameters
nameThe filter name
void removeThread ( Thread thread)

Remove a thread from workers list

Parameters
threadThe thread to remove

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