00001
00002 #ifndef INCLUDED_MessageReceiver_h_
00003 #define INCLUDED_MessageReceiver_h_
00004
00005 #ifdef PLATFORM_APERIOS
00006 # warning MessageReceiver is not Aperios compatable
00007 #else
00008
00009 #include "MessageQueue.h"
00010 #include "Thread.h"
00011
00012
00013 class MessageReceiver : public Thread {
00014 public:
00015 explicit MessageReceiver(MessageQueueBase& mq, bool (*callback) (RCRegion*)=NULL, bool startThread=true);
00016 ~MessageReceiver();
00017
00018 RCRegion * peekNextMessage();
00019 RCRegion * getNextMessage();
00020 void markRead();
00021 void waitNextMessage();
00022 unsigned int runloop();
00023 void finish();
00024
00025 void setCallback(bool (*callback) (RCRegion*)) { process=callback; }
00026
00027 protected:
00028 typedef MessageQueueBase::index_t index_t;
00029 MessageQueueBase& queue;
00030 unsigned int nextMessage;
00031 unsigned int lastProcessedMessage;
00032 bool (*process) (RCRegion*);
00033 unsigned int sleeptime;
00034 index_t curit;
00035
00036 private:
00037 MessageReceiver(const MessageReceiver& r);
00038 MessageReceiver& operator=(const MessageReceiver& r);
00039 };
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #endif //Aperios check
00053
00054 #endif //INCLUDED
00055