Flair
Framework Libre Air
Thread.h
Go to the documentation of this file.
1 // %flair:license{
2 // This file is part of the Flair framework distributed under the
3 // CECILL-C License, Version 1.0.
4 // %flair:license}
13 #ifndef THREAD_H
14 #define THREAD_H
15 
16 #include <Object.h>
17 #include <stdint.h>
18 
19 class Thread_impl;
20 
21 namespace flair {
22 namespace core {
23 
24 class IODevice;
25 
38 class Thread : public Object {
39  friend class ::Thread_impl;
40 
41 public:
49  Thread(const Object *parent, std::string name,
50  uint8_t priority); // priority>20, for real time only
51 
59  virtual ~Thread();
60 
65  void Start(void);
66 
72  void SafeStop(void);
73 
82  bool ToBeStopped(void) const;
83 
90  void Join(void);
91 
99  void SetPeriodUS(uint32_t period_us);
100 
101  uint32_t GetPeriodUS() const;
102 
110  void SetPeriodMS(uint32_t period_ms);
111 
112  uint32_t GetPeriodMS() const;
113 
120  bool IsPeriodSet(void);
121 
131  void WaitPeriod(void) const;
132 
142  int WaitUpdate(const IODevice *device);
143 
150  void Suspend(void);
151 
161  bool SuspendUntil(Time date);
162 
169  void Resume(void);
170 
177  bool IsSuspended(void) const;
178 
186  void SleepUntil(Time time) const;
187 
195  void SleepUS(uint32_t time_us) const;
196 
204  void SleepMS(uint32_t time_ms) const;
205 
217  static void WarnUponSwitches(bool enable);
218 
219 private:
227  virtual void Run(void) = 0;
228 
229  class Thread_impl *pimpl_;
230 };
231 
232 } // end namespace core
233 } // end namespace flair
234 
235 #endif // THREAD_H
void SleepUntil(Time time) const
Sleep until absolute time.
bool IsSuspended(void) const
Is the thread suspended?
Base class for all Framework's classes.
Definition: Object.h:77
Abstract class for input/ouput system.
Definition: IODevice.h:44
void SleepUS(uint32_t time_us) const
Sleep for a certain time in micro second.
namespace of the flair Framework
Definition: Ahrs.h:19
bool SuspendUntil(Time date)
Suspend the thread with timeout.
void SetPeriodUS(uint32_t period_us)
Set the period in micro second.
void Resume(void)
Resume the thread.
unsigned long long Time
Time definition, in ns.
Definition: Object.h:49
void Start(void)
Start the thread.
bool ToBeStopped(void) const
Set a stop flag.
int WaitUpdate(const IODevice *device)
Wait update of an IODevice.
static void WarnUponSwitches(bool enable)
Warn if real time / non real time switches occur.
void Join(void)
Join the thread.
void SafeStop(void)
Set a stop flag.
void SetPeriodMS(uint32_t period_ms)
Set the period in milli second.
Base class for all Framework's classes.
Abstract class for a thread.
Definition: Thread.h:38
Thread(const Object *parent, std::string name, uint8_t priority)
Constructor.
bool IsPeriodSet(void)
Returns if period was set.
void SleepMS(uint32_t time_ms) const
Sleep for a cartain time in milli second.
void WaitPeriod(void) const
Wait the period.
virtual ~Thread()
Destructor.
void Suspend(void)
Suspend the thread.