distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
Thread.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_THREAD_HPP_
13 #define INCLUDE_DISTORTOS_THREAD_HPP_
14 
16 
18 #include "distortos/SignalSet.hpp"
20 
21 #include <csignal>
22 
23 namespace distortos
24 {
25 
26 class ThreadIdentifier;
27 
34 class Thread
35 {
36 public:
37 
42  virtual ~Thread() = default;
43 
44 #ifdef DISTORTOS_THREAD_DETACH_ENABLE
45 
60  virtual int detach() = 0;
61 
62 #endif // def DISTORTOS_THREAD_DETACH_ENABLE
63 
64 #if DISTORTOS_SIGNALS_ENABLE == 1
65 
83  virtual int generateSignal(uint8_t signalNumber) = 0;
84 
85 #endif // DISTORTOS_SIGNALS_ENABLE == 1
86 
91  virtual uint8_t getEffectivePriority() const = 0;
92 
98  virtual ThreadIdentifier getIdentifier() const = 0;
99 
100 #if DISTORTOS_SIGNALS_ENABLE == 1
101 
114  virtual SignalSet getPendingSignalSet() const = 0;
115 
116 #endif // DISTORTOS_SIGNALS_ENABLE == 1
117 
122  virtual uint8_t getPriority() const = 0;
123 
128  virtual SchedulingPolicy getSchedulingPolicy() const = 0;
129 
134  virtual size_t getStackHighWaterMark() const = 0;
135 
140  virtual size_t getStackSize() const = 0;
141 
146  virtual ThreadState getState() const = 0;
147 
167  virtual int join() = 0;
168 
169 #if DISTORTOS_SIGNALS_ENABLE == 1
170 
191  virtual int queueSignal(uint8_t signalNumber, sigval value) = 0;
192 
193 #endif // DISTORTOS_SIGNALS_ENABLE == 1
194 
206  virtual void setPriority(uint8_t priority, bool alwaysBehind = {}) = 0;
207 
212  virtual void setSchedulingPolicy(SchedulingPolicy schedulingPolicy) = 0;
213 };
214 
215 } // namespace distortos
216 
217 #endif // INCLUDE_DISTORTOS_THREAD_HPP_
virtual int detach()=0
Detaches the thread.
Definition: signal.h:28
virtual ThreadState getState() const =0
virtual void setSchedulingPolicy(SchedulingPolicy schedulingPolicy)=0
virtual size_t getStackSize() const =0
SchedulingPolicy
scheduling policy of the thread
Definition: SchedulingPolicy.hpp:26
SignalSet class header.
ThreadState enum class header.
virtual size_t getStackHighWaterMark() const =0
virtual SchedulingPolicy getSchedulingPolicy() const =0
virtual uint8_t getEffectivePriority() const =0
distortos configuration
virtual uint8_t getPriority() const =0
virtual ~Thread()=default
Thread's destructor.
SignalSet class is used as a set of signals.
Definition: SignalSet.hpp:28
Top-level namespace of distortos project.
Definition: buttons.hpp:33
virtual void setPriority(uint8_t priority, bool alwaysBehind={})=0
Changes priority of thread.
virtual ThreadIdentifier getIdentifier() const =0
virtual SignalSet getPendingSignalSet() const =0
Gets set of currently pending signals.
virtual int queueSignal(uint8_t signalNumber, sigval value)=0
Queues signal for thread.
virtual int generateSignal(uint8_t signalNumber)=0
Generates signal for thread.
virtual int join()=0
Waits for thread termination.
ThreadIdentifier class is an identifier of thread.
Definition: ThreadIdentifier.hpp:52
Thread class is a pure abstract interface for threads.
Definition: Thread.hpp:34
ThreadState
state of the thread
Definition: ThreadState.hpp:28
SchedulingPolicy enum class header.