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:
50  Thread(const Object *parent, std::string name,
51  uint8_t priority,uint32_t stackSize=1024*128);
52 
60  virtual ~Thread();
61 
66  void Start(void);
67 
73  void SafeStop(void);
74 
83  bool ToBeStopped(void) const;
84 
91  void Join(void);
92 
100  void SetPeriodUS(uint32_t period_us);
101 
102  uint32_t GetPeriodUS() const;
103 
111  void SetPeriodMS(uint32_t period_ms);
112 
113  uint32_t GetPeriodMS() const;
114 
121  bool IsPeriodSet(void);
122 
132  void WaitPeriod(void) const;
133 
143  int WaitUpdate(const IODevice *device);
144 
151  void Suspend(void);
152 
162  bool SuspendUntil(Time date);
163 
170  void Resume(void);
171 
178  bool IsSuspended(void) const;
179 
186  bool IsRunning(void) const;
187 
195  void SleepUntil(Time time) const;
196 
204  void SleepUS(uint32_t time_us) const;
205 
213  void SleepMS(uint32_t time_ms) const;
214 
226  static void WarnUponSwitches(bool enable);
227 
228 private:
236  virtual void Run(void) = 0;
237 
238  class Thread_impl *pimpl_;
239 };
240 
241 } // end namespace core
242 } // end namespace flair
243 
244 #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:83
Abstract class for input/ouput system.
Definition: IODevice.h:45
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 IsRunning(void) const
Is the thread running?
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:55
void Start(void)
Start the thread.
bool ToBeStopped(void) const
Set a stop flag.
Thread(const Object *parent, std::string name, uint8_t priority, uint32_t stackSize=1024 *128)
Constructor.
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
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.