distortos  v0.7.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 class ThreadIdentifier;
23 
24 namespace ThisThread
25 {
26 
29 
30 #ifdef DISTORTOS_THREAD_DETACH_ENABLE
31 
48 int detach();
49 
50 #endif // def DISTORTOS_THREAD_DETACH_ENABLE
51 
60 __attribute__ ((noreturn))
61 void exit();
62 
69 Thread& get();
70 
77 uint8_t getEffectivePriority();
78 
85 ThreadIdentifier getIdentifier();
86 
93 uint8_t getPriority();
94 
100 
107 size_t getStackHighWaterMark();
108 
115 size_t getStackSize();
116 
128 void setPriority(uint8_t priority, bool alwaysBehind = {});
129 
134 void setSchedulingPolicy(SchedulingPolicy schedulingPolicy);
135 
151 int sleepFor(TickClock::duration duration);
152 
171 template<typename Rep, typename Period>
172 int sleepFor(const std::chrono::duration<Rep, Period> duration)
173 {
174  return sleepFor(std::chrono::duration_cast<TickClock::duration>(duration));
175 }
176 
190 int sleepUntil(TickClock::time_point timePoint);
191 
207 template<typename Duration>
208 int sleepUntil(const std::chrono::time_point<TickClock, Duration> timePoint)
209 {
210  return sleepUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint));
211 }
212 
219 void yield();
220 
222 
223 } // namespace ThisThread
224 
225 } // namespace distortos
226 
227 #endif // INCLUDE_DISTORTOS_THISTHREAD_HPP_
size_t getStackSize()
Definition: ThisThread.cpp:92
void setPriority(const uint8_t priority, const bool alwaysBehind)
Definition: ThisThread.cpp:97
int sleepFor(const TickClock::duration duration)
Makes the calling (current) thread sleep for at least given duration.
Definition: ThisThread.cpp:111
int sleepUntil(const TickClock::time_point timePoint)
Makes the calling (current) thread sleep until some time point is reached.
Definition: ThisThread.cpp:116
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:58
ThreadIdentifier getIdentifier()
Definition: ThisThread.cpp:65
void yield()
Yields time slot of the scheduler to next thread.
Definition: ThisThread.cpp:124
Top-level namespace of distortos project.
Definition: buttons.hpp:33
std::chrono::duration< rep, period > duration
basic duration type of clock
Definition: TickClock.hpp:39
Thread & get()
Definition: ThisThread.cpp:51
void exit()
Exits calling (current) thread.
Definition: ThisThread.cpp:44
int detach()
Detaches calling (current) thread.
Definition: ThisThread.cpp:37
SchedulingPolicy getSchedulingPolicy()
Definition: ThisThread.cpp:80
void setSchedulingPolicy(const SchedulingPolicy schedulingPolicy)
Definition: ThisThread.cpp:104
uint8_t getPriority()
Definition: ThisThread.cpp:73
size_t getStackHighWaterMark()
Definition: ThisThread.cpp:87
SchedulingPolicy enum class header.