Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef ORO_TIMERTHREAD_HPP
00040 #define ORO_TIMERTHREAD_HPP
00041
00042
00043 #include <list>
00044 #include <vector>
00045 #include <string>
00046 #include <boost/shared_ptr.hpp>
00047 #include <boost/weak_ptr.hpp>
00048
00049 #include "../os/Thread.hpp"
00050 #include "../os/Mutex.hpp"
00051 #include "rtt-extras-fwd.hpp"
00052
00053 namespace RTT
00054 { namespace extras {
00055
00061 typedef boost::shared_ptr<TimerThread> TimerThreadPtr;
00062
00069 class RTT_API TimerThread
00070 : public os::Thread
00071 {
00072 typedef std::vector<PeriodicActivity*> ActivityList ;
00073 ActivityList tasks;
00074 bool cleanup;
00075 public:
00076 static const unsigned int MAX_ACTIVITIES = 64;
00085 TimerThread(int priority, const std::string& name, double periodicity, unsigned cpu_affinity = ~0);
00086
00097 TimerThread(int scheduler, int priority, const std::string& name, double periodicity, unsigned cpu_affinity = ~0);
00098
00102 virtual ~TimerThread();
00103
00108 bool addActivity( PeriodicActivity* t );
00109
00110 bool removeActivity( PeriodicActivity* t );
00111
00116 static TimerThreadPtr Instance(int priority, double periodicity);
00120 static TimerThreadPtr Instance(int scheduler, int priority, double periodicity);
00124 static TimerThreadPtr Instance(int scheduler, int priority, double periodicity, unsigned cpu_affinity);
00125 protected:
00126 virtual bool initialize();
00127 virtual void step();
00128 virtual void finalize();
00129 void reorderList();
00134 mutable os::MutexRecursive mutex;
00135
00140 typedef std::vector< boost::weak_ptr<TimerThread> > TimerThreadList;
00141
00145 static TimerThreadList TimerThreads;
00146 };
00147 }}
00148
00149 #endif