Yate: MessageQueue Class Reference

Yate

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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:

## 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 NamedList & | getFilters () 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 String & | toString () const
virtual const String & | traceId () const
NamedCounter * | getObjCounter () const
NamedCounter * | setObjCounter (NamedCounter *counter)
Public Member Functions inherited from Mutex
| Mutex (bool recursive=false, const char *name=0)
| Mutex (const Mutex &original)
| ~Mutex ()
Mutex & | operator= (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 NamedCounter * | getObjCounter (const String &name, bool create=true)
static ObjList & | getObjCounters ()
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

  hookName | Name of the message served by this queue
  numWorkers | The number of workers who serve this queue

~MessageQueue | ( |  | ) |

Destroys the message queue

## Member Function Documentation

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

Add a new filter to this queue

Parameters

  name | The filter name
  value | The 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

  msg | The 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

  msg | The 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

  msg | The message to process

void removeFilter | ( | const String & | name | ) |

Remove a filter form this queue

Parameters

  name | The filter name

void removeThread | ( | Thread * | thread | ) |

Remove a thread from workers list

Parameters

  thread | The thread to remove

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

- yatengine.h