![]() |
4S Device Communication Module Collection
Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
|
|
This is a wrapper class for the class that does all the hard work. More...
#include <msgqueue.h>
Static Public Member Functions | |
static void | addListenerToQueue (MsgAddr &receiverAddr, const std::type_info &typeOfMsg, MsgCallBack *msgCallBack) |
Function that registers a listener to the message queue. More... | |
static void | removeListenerFromQueue (MsgCallBack *msgCallBack) |
Function that unregisters a listener from the message queue. More... | |
static void | waitUntilQueueHasData (void) |
Function that halts the current thread execution. More... | |
static void | emptyMsgQueue (int maxTimeMs=-1) |
The function will process messages on the message queue. More... | |
static void | breakEmptyMsgQueue (void) |
Breaks out of emptyMsgQueue. More... | |
static bool | isEmpty (void) |
Function to determine if there is data on the msg queue. More... | |
static Handle | getHandle (void) |
Retrieves the handle of the queue for the current thread. More... | |
The MsgQueue class is a wrapper class with the public interface for the message queue. It contains the functions that gives the caller the ability to:
|
static |
This function registers a listener (the ability of a class to receive a given type of message) with the queue of the thread that the function is called from.
receiverAddr | Address of the receiver |
typeOfMsg | |
msgCallBack |
|
static |
Function must be called from a message handler (directly or indirectly) and will cause the message loop internal to the emptyMsgQueue function to break.
This function is used in the case where you have a component that as part of its operation sends messages to it self.
Usually the emptyMsgQueue function will only return when the message is queue is empty, but in the case where components on the queue keeps sending to other components in the same thread, the queue will never be empty and hence will never terminate.
Calling this function will break the msg loop.
|
static |
This function is used for processing messages from the message queue of the thread that this function is called from.
The default behavior is for the function to run until there are no more messages on the queue at which point the function will return.
It is possible to give an optional argument to the function limiting the time it will run.
maxTimeMs | The maximum time in MS that will pass before the function breaks the loop that empties the queue. |
maxTimeMs < 0 => Run until the queue is empty or breakEmptyMsgQueue() is called
maxTimeMS == 0 => Run until all messages on the queue at the time of the call are processed
maxTimeMS > 0 => Run approximately until maxTimeMS have passed
|
static |
This function can be used by threads to identify which queue they belong to.
|
static |
Call this function to determine if there are messages waiting to be processed on the queue.
|
static |
This function removes a listener from the internal datastructures of the message queue.
msgCallBack | Pointer to the callback that should be removed |
|
static |
This function halts the current thread until someone sends a message to the thread. Be careful not the halt all of your threads, since in that case no-one will be able to send any messages to wake the system up again.