SingleThread.hpp
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 SINGLE_THREAD_HPP
00040 #define SINGLE_THREAD_HPP
00041
00042
00043 #include "../rtt-config.h"
00044 #include "fosi.h"
00045
00046 #include "RunnableInterface.hpp"
00047 #include "ThreadInterface.hpp"
00048 #include "Mutex.hpp"
00049
00050 #include <string>
00051
00052 namespace RTT
00053 {
00054 class DigitalOutInterface;
00055
00056 namespace OS {
00084 class SingleThread
00085 : public OS::ThreadInterface
00086 {
00087 friend void* singleThread_f( void* t );
00088 public:
00097 SingleThread(int priority, const std::string& name, OS::RunnableInterface* r=0);
00098
00108 SingleThread(int scheduler, int priority, const std::string& name, OS::RunnableInterface* r=0);
00109
00110 virtual ~SingleThread();
00111
00112 virtual bool run( OS::RunnableInterface* r);
00113
00124 virtual bool start();
00125
00137 virtual bool stop();
00138
00142 virtual bool isRunning() const;
00143
00147 virtual bool isActive() const;
00148
00152 virtual const char* getName() const;
00157 virtual RTOS_TASK * getTask(){return &(this->rtos_task);};
00158
00159 virtual bool setScheduler(int sched_type);
00160 virtual int getScheduler() const;
00161
00162 virtual Seconds getPeriod() const { return 0.0; }
00163 virtual nsecs getPeriodNS() const { return 0; }
00164
00165 virtual bool setPriority(int priority);
00166
00167 virtual int getPriority() const;
00168
00169 virtual void yield();
00170
00171 protected:
00172
00173 virtual bool breakLoop();
00174
00175 virtual void loop();
00176
00177 virtual bool initialize();
00178
00179 virtual void finalize();
00180
00181 private:
00182 void setup(int _priority, const std::string& name);
00183
00187 int msched_type;
00188
00193 bool active;
00194
00198 bool prepareForExit;
00199
00203 bool inloop;
00204
00208 bool runloop;
00209
00213 RTOS_TASK rtos_task;
00214
00218 rt_sem_t sem;
00219
00224 rt_sem_t confDone;
00225
00229 OS::RunnableInterface* runComp;
00230
00234 MutexRecursive breaker;
00235
00236 #ifdef OROPKG_OS_THREAD_SCOPE
00237
00238 DigitalOutInterface * d;
00239 #endif
00240 };
00241
00242 }}
00243
00244 #endif