CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/EventFilter/ResourceBroker/interface/CommandQueue.h

Go to the documentation of this file.
00001 
00002 //
00003 // CommandQueue.h
00004 // -------
00005 //
00006 //  Created on: Dec 13, 2011
00007 //                                                                              Andrei Spataru : aspataru@cern.ch
00009 
00010 #ifndef COMMANDQUEUE_H_
00011 #define COMMANDQUEUE_H_
00012 
00013 #include "boost/statechart/event_base.hpp"
00014 #include <boost/shared_ptr.hpp>
00015 
00016 #include <queue>
00017 #include <semaphore.h>
00018 
00019 namespace evf {
00020 
00021 namespace rb_statemachine {
00022 
00023 typedef boost::shared_ptr<boost::statechart::event_base> EventPtr;
00024 
00032 class CommandQueue {
00033 
00034 public:
00035         CommandQueue();
00036         ~CommandQueue();
00037 
00041         void enqEvent(EventPtr event);
00042 
00046         EventPtr deqEvent();
00047 
00048 private:
00049         void lock();
00050         void unlock();
00051 
00052 private:
00053         std::queue<EventPtr> eventQueue_;
00054         sem_t lock_;
00055         // counting semaphore used to reflect the state of the event queue
00056         sem_t commandsSem_;
00057 };
00058 
00059 }
00060 }
00061 
00062 #endif /* COMMANDQUEUE_H_ */