Thread safe message queue


Typedefs

typedef struct MessageQ_s * MessageQ_t
 Message Queue handle.

Functions

MessageQ_t MessageQCreate ()
 Creates a new double linked list.
void MessageQDestroy (MessageQ_t msgQ)
 Frees the specified message queue.
void MessageQSend (MessageQ_t msgQ, void *msg)
 Sends the specified msg to the message queue.
int MessageQAvailable (MessageQ_t msgQ)
 Returns the number of messages waiting in the queue.
void * MessageQReceive (MessageQ_t msgQ)
 Receive a message from the queue, the return object should be unref'ed once finished with via ObjectRefDec.
void MessageQSetQuit (MessageQ_t msgQ)
 Set the quit flag on the specified message queue.
void MessageQResetQuit (MessageQ_t msgQ)
 Reset the quit flag on the specified message queue so messages can once again be received.
bool MessageQIsQuitSet (MessageQ_t msgQ)
 Test whether the quit flag is set on the specified message queue.

Function Documentation

int MessageQAvailable ( MessageQ_t  msgQ  ) 

Returns the number of messages waiting in the queue.

Parameters:
msgQ The message queue to count the waiting messages in.
Returns:
The number of waiting messages.

MessageQ_t MessageQCreate (  ) 

Creates a new double linked list.

Returns:
A new MessageQ_t instance or NULL if there is not enough memory.

void MessageQDestroy ( MessageQ_t  msgQ  ) 

Frees the specified message queue.

Parameters:
msgQ The message queue to free.

bool MessageQIsQuitSet ( MessageQ_t  msgQ  ) 

Test whether the quit flag is set on the specified message queue.

Parameters:
msgQ The message queue to check.
Returns:
TRUE if the quit flag is set, FALSE otherwise.

void* MessageQReceive ( MessageQ_t  msgQ  ) 

Receive a message from the queue, the return object should be unref'ed once finished with via ObjectRefDec.

If the quit flag is set on the message queue NULL will be returned.

Parameters:
msgQ The queue to receive a message from.
Returns:
A pointer to an object or NULL if quit is set.

void MessageQResetQuit ( MessageQ_t  msgQ  ) 

Reset the quit flag on the specified message queue so messages can once again be received.

Parameters:
msgQ The message queue to reset the quit flag on.

void MessageQSend ( MessageQ_t  msgQ,
void *  msg 
)

Sends the specified msg to the message queue.

msg must be allocated using Object(Alloc/Create) as on adding to the queue they will have their reference count increased using ObjectRefInc and any messages are left in the queue when it is destroyed they will first be unref'ed using ObjectRefDec().

Parameters:
msgQ The message queue to send the message to.
msg The object to send.

void MessageQSetQuit ( MessageQ_t  msgQ  ) 

Set the quit flag on the specified message queue.

Once set all current and future calls to MessageQReceive will return NULL.

Parameters:
msgQ The message queue to set the quit flag on.


Generated on Thu Jun 26 12:58:31 2008 for DVBStreamer by  doxygen 1.5.5