distortos  v0.5.0
object-oriented C++ RTOS for microcontrollers
ThisThread.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_THISTHREAD_HPP_
13 #define INCLUDE_DISTORTOS_THISTHREAD_HPP_
14 
16 #include "distortos/TickClock.hpp"
17 
18 namespace distortos
19 {
20 
21 class Thread;
22 
23 namespace ThisThread
24 {
25 
28 
29 #ifdef CONFIG_THREAD_DETACH_ENABLE
30 
47 int detach();
48 
49 #endif // def CONFIG_THREAD_DETACH_ENABLE
50 
57 Thread& get();
58 
65 uint8_t getEffectivePriority();
66 
73 uint8_t getPriority();
74 
80 
87 size_t getStackHighWaterMark();
88 
95 size_t getStackSize();
96 
108 void setPriority(uint8_t priority, bool alwaysBehind = {});
109 
114 void setSchedulingPolicy(SchedulingPolicy schedulingPolicy);
115 
131 int sleepFor(TickClock::duration duration);
132 
151 template<typename Rep, typename Period>
152 int sleepFor(const std::chrono::duration<Rep, Period> duration)
153 {
154  return sleepFor(std::chrono::duration_cast<TickClock::duration>(duration));
155 }
156 
170 int sleepUntil(TickClock::time_point timePoint);
171 
187 template<typename Duration>
188 int sleepUntil(const std::chrono::time_point<TickClock, Duration> timePoint)
189 {
190  return sleepUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint));
191 }
192 
199 void yield();
200 
202 
203 } // namespace ThisThread
204 
205 } // namespace distortos
206 
207 #endif // INCLUDE_DISTORTOS_THISTHREAD_HPP_
void setPriority(uint8_t priority, bool alwaysBehind={})
Definition: ThisThread.cpp:80
size_t getStackSize()
Definition: ThisThread.cpp:75
int sleepFor(TickClock::duration duration)
Makes the calling (current) thread sleep for at least given duration.
Definition: ThisThread.cpp:94
int sleepUntil(TickClock::time_point timePoint)
Makes the calling (current) thread sleep until some time point is reached.
Definition: ThisThread.cpp:99
SchedulingPolicy
scheduling policy of the thread
Definition: SchedulingPolicy.hpp:26
std::chrono::time_point< TickClock > time_point
basic time_point type of clock
Definition: TickClock.hpp:42
TickClock class header.
uint8_t getEffectivePriority()
Definition: ThisThread.cpp:49
void setSchedulingPolicy(SchedulingPolicy schedulingPolicy)
Definition: ThisThread.cpp:87
void yield()
Yields time slot of the scheduler to next thread.
Definition: ThisThread.cpp:107
Top-level namespace of distortos project.
std::chrono::duration< rep, period > duration
basic duration type of clock
Definition: TickClock.hpp:39
int detach()
Detaches calling (current) thread.
Definition: ThisThread.cpp:35
SchedulingPolicy getSchedulingPolicy()
Definition: ThisThread.cpp:63
uint8_t getPriority()
Definition: ThisThread.cpp:56
size_t getStackHighWaterMark()
Definition: ThisThread.cpp:70
SchedulingPolicy enum class header.