MessageDispatcher Class Reference
A message dispatching hub.
More...
#include <yatengine.h>
List of all members.
Detailed Description
A message dispatching hub.
The dispatcher class is a hub that holds a list of handlers to be called for the messages that pass trough the hub. It can also handle a queue of messages that are typically dispatched by a separate thread.
Constructor & Destructor Documentation
Creates a new message dispatcher.
Destroys the dispatcher and the installed handlers.
Member Function Documentation
Clear all the message handlers and post-dispatch hooks
Dispatch all messages from the waiting queue
Dispatch one message from the waiting queue
- Returns:
- True if success, false if the queue is empty
Synchronously dispatch a message to the installed handlers. Handlers matching the message name and filter parameter are called in their installed order (based on priority) until one returns true. Note that in some cases when a handler is removed from the list other handlers with equal priority may be called twice.
- Parameters:
-
| msg | The message to dispatch |
- Returns:
- True if one handler accepted it, false if all ignored
Put a message in the waiting queue for asynchronous dispatching
- Parameters:
-
| msg | The message to enqueue, will be destroyed after dispatching |
- Returns:
- True if successfully queued, false otherwise
unsigned int handlerCount |
( |
|
) |
|
Get the number of handlers in this dispatcher
- Returns:
- Count of handlers
Installs a handler in the dispatcher. The handlers are installed in ascending order of their priorities. There is NO GUARANTEE on the order of handlers with equal priorities although for avoiding uncertainity such handlers are sorted by address.
- Parameters:
-
| handler | A pointer to the handler to install |
- Returns:
- True on success, false on failure
unsigned int messageCount |
( |
|
) |
|
Get the number of messages waiting in the queue
- Returns:
- Count of messages in the queue
Install or remove a hook to catch messages after being dispatched
- Parameters:
-
| hook | Pointer to a post-dispatching message hook |
| remove | Set to True to remove the hook instead of adding |
Uninstalls a handler from the dispatcher.
- Parameters:
-
| handler | A pointer to the handler to uninstall |
- Returns:
- True on success, false on failure
void warnTime |
( |
u_int64_t |
usec |
) |
[inline] |
Set a limit to generate warning when a message took too long to dispatch
- Parameters:
-
| usec | Warning time limit in microseconds, zero to disable |
The documentation for this class was generated from the following file: