sipxportlib  Version 3.3
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
OsMsgQBase Class Referenceabstract

#include <OsMsgQ.h>

Inheritance diagram for OsMsgQBase:
Inheritance graph
[legend]
Collaboration diagram for OsMsgQBase:
Collaboration graph
[legend]

Public Types

enum  Options { Q_FIFO = 0x0, Q_PRIORITY = 0x1 }
 

Public Member Functions

 OsMsgQBase (const UtlString &name)
 Constructor. More...
 
virtual ~OsMsgQBase ()
 Destructor. More...
 
virtual OsStatus send (const OsMsg &rMsg, const OsTime &rTimeout=OsTime::OS_INFINITY)=0
 Insert a copy of the message at the tail of the queue. More...
 
virtual OsStatus sendNoCopy (OsMsg *pMsg, const OsTime &rTimeout=OsTime::OS_INFINITY)=0
 Insert an original of the message at the tail of the queue. More...
 
virtual OsStatus sendUrgent (const OsMsg &rMsg, const OsTime &rTimeout=OsTime::OS_INFINITY)=0
 Insert a copy of the message at the head of the queue. More...
 
virtual OsStatus sendFromISR (OsMsg &rMsg)=0
 Insert a copy of the message at the tail of the queue with ISR flag. More...
 
virtual OsStatus receive (OsMsg *&rpMsg, const OsTime &rTimeout=OsTime::OS_INFINITY)=0
 Remove a message from the head of the queue. More...
 
virtual void flush ()
 Delete all messages currently in the queue. More...
 
virtual void setSendHook (OsMsgQSendHookPtr func)
 Set the function that is invoked whenever a msg is sent to the queue. More...
 
virtual void setFlushHook (OsMsgQFlushHookPtr func)
 Set the function that is invoked whenever a msg is flushed from the queue. More...
 
virtual int numMsgs ()=0
 Return the number of messages in the queue. More...
 
int maxMsgs () const
 Returns the maximum number of messages that can be queued. More...
 
virtual OsMsgQSendHookPtr getSendHook () const
 Return a pointer to the current send hook function. More...
 
virtual UtlBoolean isEmpty ()
 Return TRUE if the message queue is empty, FALSE otherwise. More...
 
const UtlStringgetName () const
 Get the name associated with the queue. More...
 

Static Public Member Functions

static OsMsgQBasegetMsgQByName (const UtlString &name)
 Return a pointer to the named queue, or NULL if not found. More...
 

Static Public Attributes

static const int DEF_MAX_MSGS = 100
 Default maximum number of messages. More...
 
static const int DEF_MAX_MSG_LEN = 32
 Default maximum msg length (in bytes) More...
 
static const UtlString MSGQ_PREFIX
 Prefix for OsMsgQ names stored in < the name database. More...
 

Protected Attributes

OsMsgQSendHookPtr mSendHookFunc
 Method that is invoked whenever a message is sent to the queue. More...
 
OsMsgQFlushHookPtr mFlushHookFunc
 Method that is invoked whenever a message is flushed from the queue. More...
 
int mMaxMsgs
 maximum number of messages the queue can hold More...
 

Member Enumeration Documentation

enum Options
Enumerator
Q_FIFO 

queue blocked tasks on a first-in, first-out basis

Q_PRIORITY 

queue blocked tasks based on their priority

Constructor & Destructor Documentation

OsMsgQBase ( const UtlString name)

Constructor.

If name is specified but is already in use, throw an exception.

~OsMsgQBase ( )
virtual

Destructor.

Member Function Documentation

OsMsgQBase * getMsgQByName ( const UtlString name)
static

Return a pointer to the named queue, or NULL if not found.

virtual OsStatus send ( const OsMsg rMsg,
const OsTime rTimeout = OsTime::OS_INFINITY 
)
pure virtual

Insert a copy of the message at the tail of the queue.

Wait until there is either room on the queue or the timeout expires.

This method creates a copy of the pMsg, before inserting it to the queue.

Implemented in OsMsgQShared.

virtual OsStatus sendNoCopy ( OsMsg pMsg,
const OsTime rTimeout = OsTime::OS_INFINITY 
)
pure virtual

Insert an original of the message at the tail of the queue.

Wait until there is either room on the queue or the timeout expires.

This method does not create a copy of the pMsg, inserting it to the queue as is.

Implemented in OsMsgQShared.

virtual OsStatus sendUrgent ( const OsMsg rMsg,
const OsTime rTimeout = OsTime::OS_INFINITY 
)
pure virtual

Insert a copy of the message at the head of the queue.

Wait until there is either room on the queue or the timeout expires.

Implemented in OsMsgQShared.

virtual OsStatus sendFromISR ( OsMsg rMsg)
pure virtual

Insert a copy of the message at the tail of the queue with ISR flag.

Sending from an ISR has a couple of implications. Since we can't allocate memory within an ISR, we don't create a copy of the message before sending it and the sender and receiver need to agree on a protocol (outside this class) for when the message can be freed. The sentFromISR flag in the OsMsg object will be TRUE for messages sent using this method.

Implemented in OsMsgQShared.

virtual OsStatus receive ( OsMsg *&  rpMsg,
const OsTime rTimeout = OsTime::OS_INFINITY 
)
pure virtual

Remove a message from the head of the queue.

Wait until either a message arrives or the timeout expires. Other than for messages sent from an ISR, the receiver is responsible for freeing the received message.

Implemented in OsMsgQShared.

void flush ( void  )
virtual

Delete all messages currently in the queue.

void setSendHook ( OsMsgQSendHookPtr  func)
virtual

Set the function that is invoked whenever a msg is sent to the queue.

The function takes the message to be sent as an argument and returns a boolean value indicating whether the SendHook method has handled the message. If TRUE, the message is not inserted into the queue (since it has already been handled. If FALSE, the (possibly modified) message is inserted into the queue.

void setFlushHook ( OsMsgQFlushHookPtr  func)
virtual

Set the function that is invoked whenever a msg is flushed from the queue.

Messages get flushed when the OsMsgQ is deleted while there are messages still queued.

The function takes an OsMsg reference as an argument.

virtual int numMsgs ( )
pure virtual

Return the number of messages in the queue.

Implemented in OsMsgQShared.

int maxMsgs ( ) const

Returns the maximum number of messages that can be queued.

OsMsgQSendHookPtr getSendHook ( void  ) const
virtual

Return a pointer to the current send hook function.

UtlBoolean isEmpty ( void  )
virtual

Return TRUE if the message queue is empty, FALSE otherwise.

const UtlString& getName ( ) const
inline

Get the name associated with the queue.

Member Data Documentation

const int DEF_MAX_MSGS = 100
static

Default maximum number of messages.

const int DEF_MAX_MSG_LEN = 32
static

Default maximum msg length (in bytes)

const UtlString MSGQ_PREFIX
static

Prefix for OsMsgQ names stored in < the name database.

OsMsgQSendHookPtr mSendHookFunc
protected

Method that is invoked whenever a message is sent to the queue.

OsMsgQFlushHookPtr mFlushHookFunc
protected

Method that is invoked whenever a message is flushed from the queue.

int mMaxMsgs
protected

maximum number of messages the queue can hold