distortos  v0.4.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 
15 #include "distortos/TickClock.hpp"
16 
17 namespace distortos
18 {
19 
20 class Thread;
21 
22 namespace ThisThread
23 {
24 
27 
28 #ifdef CONFIG_THREAD_DETACH_ENABLE
29 
46 int detach();
47 
48 #endif // def CONFIG_THREAD_DETACH_ENABLE
49 
56 Thread& get();
57 
64 uint8_t getEffectivePriority();
65 
72 uint8_t getPriority();
73 
80 size_t getStackHighWaterMark();
81 
88 size_t getStackSize();
89 
101 void setPriority(uint8_t priority, bool alwaysBehind = {});
102 
118 int sleepFor(TickClock::duration duration);
119 
138 template<typename Rep, typename Period>
139 int sleepFor(const std::chrono::duration<Rep, Period> duration)
140 {
141  return sleepFor(std::chrono::duration_cast<TickClock::duration>(duration));
142 }
143 
157 int sleepUntil(TickClock::time_point timePoint);
158 
174 template<typename Duration>
175 int sleepUntil(const std::chrono::time_point<TickClock, Duration> timePoint)
176 {
177  return sleepUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint));
178 }
179 
186 void yield();
187 
189 
190 } // namespace ThisThread
191 
192 } // namespace distortos
193 
194 #endif // INCLUDE_DISTORTOS_THISTHREAD_HPP_
void setPriority(uint8_t priority, bool alwaysBehind={})
Definition: ThisThread.cpp:73
size_t getStackSize()
Definition: ThisThread.cpp:68
int sleepFor(TickClock::duration duration)
Makes the calling (current) thread sleep for at least given duration.
Definition: ThisThread.cpp:80
int sleepUntil(TickClock::time_point timePoint)
Makes the calling (current) thread sleep until some time point is reached.
Definition: ThisThread.cpp:85
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 yield()
Yields time slot of the scheduler to next thread.
Definition: ThisThread.cpp:93
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
uint8_t getPriority()
Definition: ThisThread.cpp:56
size_t getStackHighWaterMark()
Definition: ThisThread.cpp:63