msg_queue_manager.h
Go to the documentation of this file.
00001 
00023 #ifndef MSG_QUEUE_MANAGER_H_
00024 #define MSG_QUEUE_MANAGER_H_
00025    
00026 #include <iostream>
00027 #include <boost/thread.hpp>
00028 #include "micros_swarm/circular_queue.h"
00029 
00030 namespace micros_swarm{
00031 
00032     class MsgQueueManager;
00033 
00034     class OutMsgQueue
00035     {
00036     public:
00037         OutMsgQueue(const std::string& name, int size, MsgQueueManager *manager_ptr);
00038         ~OutMsgQueue();
00039         bool full();
00040         bool empty();
00041         int size();
00042         const std::vector<uint8_t>& front();
00043         void pop();
00044         void push(const std::vector<uint8_t>& msg);
00045     private:
00046         std::string name_;
00047         int size_;
00048         MsgQueueManager *queue_manager_ptr_;
00049         boost::shared_mutex mutex_;
00050         boost::shared_ptr<cqueue<std::vector<uint8_t> > > queue_;
00051     };
00052 
00053     class MsgQueueManager
00054     {
00055         public:
00056             MsgQueueManager();
00057             ~MsgQueueManager();
00058             void createOutMsgQueue(std::string name, int size);
00059             OutMsgQueue* getOutMsgQueue(std::string name);
00060             void spinAllOutMsgQueueOnce(std::vector<std::vector<uint8_t> >& msg_vec);
00061             bool allOutMsgQueueEmpty();
00062             
00063             boost::shared_mutex msg_queue_mutex;
00064             boost::condition_variable_any msg_queue_condition;
00065         private:
00066             std::map<std::string, OutMsgQueue*> queue_map_;
00067     };
00068 };
00069 
00070 #endif


micros_swarm
Author(s):
autogenerated on Thu Jun 6 2019 18:52:14