00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #ifndef LOCAL_MSG_QUEUE_H_ 00004 #define LOCAL_MSG_QUEUE_H_ 00005 00006 #include <fesa-core/Core/AbstractMsgQueue.h> 00007 #include <fesa-core/Utilities/Mutex.h> 00008 #include <fesa-core/Utilities/ConditionalVariable.h> 00009 00010 #include <string> 00011 #include <queue> 00012 00013 namespace fesa 00014 { 00015 00021 class LocalMsgQueue : public AbstractMsgQueue 00022 { 00023 public: 00024 00030 LocalMsgQueue(const std::string& name, uint32_t queueLength); 00031 00035 ~LocalMsgQueue(); 00036 00042 void postMsg(AbstractMessage* msg); 00043 00049 AbstractMessage* consumeMsg(); 00050 00054 void purge(); 00055 00060 uint32_t getCurrentMsgCount(); 00061 00062 00063 private: 00064 00068 std::priority_queue<AbstractMessage*> msgQueue_; 00069 00073 Mutex accessMutex_; 00074 00078 ConditionalVariable newMsgCondVar_; 00079 00083 LocalMsgQueue(const LocalMsgQueue&); 00084 00088 LocalMsgQueue& operator=(const LocalMsgQueue&); 00089 }; 00090 00091 } // fesa 00092 00093 #endif // LOCAL_MSG_QUEUE_H_