RTScheduler.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef RT_SCHEDULER_H_
00004 #define RT_SCHEDULER_H_
00005 
00006 #include <fesa-core/Diagnostic/DiagnosticUtils.h>
00007 #include <fesa-core/Utilities/Thread.h>
00008 #include <fesa-core/Utilities/Mutex.h>
00009 #include <fesa-core/Utilities/ConditionalVariable.h>
00010 
00011 #include <string>
00012 #include <map>
00013 #include <vector>
00014 #include <deque>
00015 
00016 #include <boost/shared_ptr.hpp>
00017 
00018 namespace fesa
00019 {
00020 
00021 class RTEvent;
00022 class AbstractRTAction;
00023 class FesaStream;
00024 
00030 class RTScheduler : public Thread
00031 {
00032   public:
00033 
00034 
00041     RTScheduler(const std::string& name, int32_t eventQueueSize);
00042 
00048     void post(boost::shared_ptr<RTEvent>& pEv);
00049 
00055     void addRTAction(const std::string& eventName, AbstractRTAction* rtAction);
00056 
00057     const std::string& getName();
00058 
00062     virtual ~RTScheduler();
00063 
00070     void printState(FesaStream* fesaStream, double elapsedTime);
00071 
00075     void printConfig(FesaStream* fesaStream);
00076 
00080     void cancel();
00081 
00082   private:
00083 
00088     std::map<const std::string, std::vector<AbstractRTAction*> > schedulingMap_;
00089 
00094     std::deque<boost::shared_ptr<RTEvent> > eventQueue_;
00095 
00100     std::string name_;
00101 
00106     int32_t queueSize_;
00107 
00112     Mutex mutexQueue_;
00113 
00118     ConditionalVariable conditionalVariableQueue_;
00119 
00123     void run();
00124 
00128     void schedule(RTEvent* event);
00129 
00133     void logDiagnostics(RTEvent*& pEvent);
00134 
00135     //Diagnostic status
00136     DiagnosticUtils::DiagStateCounter postEventCount_;
00137     DiagnosticUtils::DiagStateCounter scheduledEventCount_;
00138     DiagnosticUtils::DiagStateCounter accumulatedEventCount_;
00139     uint32_t lostEventCount_;
00140 };
00141 
00142 /**********************************************************************************/
00143 
00144 inline const std::string& RTScheduler::getName()
00145 {
00146     return name_;
00147 }
00148 
00149 } // fesa
00150 
00151 #endif // RT_SCHEDULER_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1