Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
MessageReceiver Class Reference#include <MessageReceiver.h>
Inheritance diagram for MessageReceiver:
![]() Detailed DescriptionSpawns a thread for monitoring a MessageQueue, calls a specified function when new messages are available.Uses a semaphore which is raised by the MessageQueue itself when a new message is posted. This should have almost no overhead, and fairly low latency (at least, much lower latency than you would get by running multiple busy loops polling for new messages) Keep in mind that the monitor runs in a separate thread, so you will need to consider mutex issues when the callback is executing. Definition at line 19 of file MessageReceiver.h.
Member Typedef Documentation
Constructor & Destructor Documentation
constructor, indicate the message queue, and optional callback function and whether to start the monitor right away
Definition at line 9 of file MessageReceiver.cc.
don't call
Member Function Documentation
returns the next unread message without marking it read, or NULL if there are currently no more messages. MessageReceiver retains reference.
Definition at line 32 of file MessageReceiver.cc. Referenced by processNextMessage().
returns the next unread message, marking it as read. Caller inherits reference, and should call RemoveReference when done.
Definition at line 40 of file MessageReceiver.cc.
marks the current message as read, and allows MessageQueue to process next unread message
Definition at line 36 of file MessageReceiver.h. Referenced by processNextMessage().
thread control -- stop monitoring (can call start() later to resume)
Reimplemented from Thread. Definition at line 50 of file MessageReceiver.cc. Referenced by finish(), and ~MessageReceiver().
thread control -- stop(), join(), and process any final messages in the queue; unsubscribes as a listener of the MessageQueue
Definition at line 67 of file MessageReceiver.cc. Referenced by MotionManager::RemoveAccess().
allows you to change the callback function -- should be set before the thread is started (otherwise, why bother starting it?)
Definition at line 44 of file MessageReceiver.h.
sets curit to the oldest message which hasn't been marked read
Definition at line 55 of file MessageReceiver.cc. Referenced by getNextMessage(), markRead(), and peekNextMessage().
register as a listener with the queue, if we haven't already (retains listener status between stop/start)
Reimplemented from Thread. Definition at line 80 of file MessageReceiver.cc.
wait for a new message, and then process it
Reimplemented from Thread. Definition at line 90 of file MessageReceiver.cc.
wait for semid to be raised to indicate a new message is in the queue (or at least, that it needs to be checked); returns false if interrupted
Definition at line 101 of file MessageReceiver.cc. Referenced by runloop().
if checksNext is set, raises semid so that if additional messages came in while we were processing the current one, they will be picked up
Definition at line 126 of file MessageReceiver.cc.
don't call
Member Data Documentation
the MessageQueue being monitored
Definition at line 56 of file MessageReceiver.h. Referenced by findCurrentMessage(), finish(), getNextMessage(), launched(), markRead(), MessageReceiver(), peekNextMessage(), processNextMessage(), runloop(), stop(), waitNextMessage(), and ~MessageReceiver().
the semaphore raised when the queue should be checked for new messages
Definition at line 57 of file MessageReceiver.h. Referenced by finish(), getNextMessage(), launched(), markRead(), MessageReceiver(), runloop(), stop(), waitNextMessage(), and ~MessageReceiver().
the expected serial number of the next message to be sent
Definition at line 58 of file MessageReceiver.h. Referenced by findCurrentMessage(), getNextMessage(), and markRead().
the serial number of the last received message
Definition at line 59 of file MessageReceiver.h. Referenced by processNextMessage().
the message id of the last received message (currently being processed)
Definition at line 61 of file MessageReceiver.h. Referenced by findCurrentMessage(), getNextMessage(), markRead(), peekNextMessage(), and processNextMessage().
The documentation for this class was generated from the following files: |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:58:32 2007 by Doxygen 1.5.4 |