AsyncEventHandler.hh

Go to the documentation of this file.
00001 
00007 #ifndef ASYNC_EVENT_HANDLER_h
00008 #define ASYNC_EVENT_HANDLER_h
00009 
00010 #ifndef SINGLETHREAD
00011 #include "boost/thread/condition_variable.hpp"
00012 #include "boost/thread/mutex.hpp"
00013 #include "boost/thread.hpp"
00014 #endif
00015 
00016 #include "Event.hh"
00017 #include <vector>
00018 
00019 class BaseModule;
00020 
00026 class AsyncEventHandler{
00027 public:
00028   AsyncEventHandler();
00029   ~AsyncEventHandler();
00030   
00032   void Reset();
00033   
00035   int AddModule(BaseModule* mod, bool register_to_eventhandler = true,
00036                 bool register_parameters = true);
00037   
00039   int AddReceiver(AsyncEventHandler* receiver);
00040   
00042   int Process(EventPtr evt);
00043   
00045   int StartRunning();
00047   int StopRunning();
00049   bool IsRunning(){ return _running; }
00050   
00052   void SetSleepMillisec(int sleeptime){ _sleeptime = sleeptime;}
00054   int GetSleepMillisec() const { return _sleeptime; }
00055   
00057   void SetBlockingStatus(bool blocking){ _blocking = blocking; }
00059   bool GetBlockingStatus(){ return _blocking; }
00060   
00062   void operator()();  
00063 
00064 private:
00065   bool _running;            
00066   int _sleeptime;           
00067   bool _blocking;           
00068   std::vector<BaseModule*> _modules;          
00069   std::vector<AsyncEventHandler*> _receivers; 
00070   EventPtr _next_event;                  
00071 #ifndef SINGLETHREAD
00072   boost::condition_variable _event_ready; 
00073   boost::mutex _event_mutex;      
00074   boost::shared_ptr<boost::thread> _threadptr; 
00075 #endif
00076 };  
00077 
00078 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1