distortos
v0.7.0
object-oriented C++ RTOS for microcontrollers
|
Threads-related API of distortos. More...
Classes | |
class | distortos::DynamicThread |
DynamicThread class is a type-erased interface for thread that has dynamic storage for bound function, stack and internal DynamicSignalsReceiver object. More... | |
struct | distortos::DynamicThreadParameters |
DynamicThreadParameters struct is a helper with parameters for DynamicThread's constructor. More... | |
class | distortos::StaticThread< StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args > |
StaticThread class is a templated interface for thread that has automatic storage for stack. More... | |
class | distortos::StaticThread< StackSize, true, QueuedSignals, SignalActions, Function, Args... > |
StaticThread class is a templated interface for thread that has automatic storage for stack and internal StaticSignalsReceiver object. More... | |
class | distortos::Thread |
Thread class is a pure abstract interface for threads. More... | |
class | distortos::ThreadIdentifier |
ThreadIdentifier class is an identifier of thread. More... | |
class | distortos::UndetachableThread |
UndetachableThread class is a ThreadCommon that cannot be detached. More... | |
Enumerations | |
enum | distortos::SchedulingPolicy : uint8_t { distortos::SchedulingPolicy::fifo, distortos::SchedulingPolicy::roundRobin } |
scheduling policy of the thread More... | |
enum | distortos::ThreadState : uint8_t { distortos::ThreadState::created, distortos::ThreadState::runnable, distortos::ThreadState::terminated, distortos::ThreadState::sleeping, distortos::ThreadState::blockedOnSemaphore, distortos::ThreadState::suspended, distortos::ThreadState::blockedOnMutex, distortos::ThreadState::blockedOnConditionVariable, distortos::ThreadState::waitingForSignal, distortos::ThreadState::detached } |
state of the thread More... | |
Functions | |
template<typename Function , typename... Args> | |
DynamicThread | distortos::makeDynamicThread (const size_t stackSize, const bool canReceiveSignals, const size_t queuedSignals, const size_t signalActions, const uint8_t priority, const SchedulingPolicy schedulingPolicy, Function &&function, Args &&... args) |
Helper factory function to make DynamicThread object. More... | |
template<typename Function , typename... Args> | |
DynamicThread | distortos::makeDynamicThread (const DynamicThreadParameters parameters, Function &&function, Args &&... args) |
Helper factory function to make DynamicThread object. More... | |
template<typename Function , typename... Args> | |
DynamicThread | distortos::makeAndStartDynamicThread (const size_t stackSize, const bool canReceiveSignals, const size_t queuedSignals, const size_t signalActions, const uint8_t priority, const SchedulingPolicy schedulingPolicy, Function &&function, Args &&... args) |
Helper factory function to make and start DynamicThread object. More... | |
template<typename Function , typename... Args> | |
DynamicThread | distortos::makeAndStartDynamicThread (const DynamicThreadParameters parameters, Function &&function, Args &&... args) |
Helper factory function to make and start DynamicThread object. More... | |
template<size_t StackSize, bool CanReceiveSignals = {}, size_t QueuedSignals = {}, size_t SignalActions = {}, typename Function , typename... Args> | |
StaticThread< StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args... > | distortos::makeStaticThread (const uint8_t priority, const SchedulingPolicy schedulingPolicy, Function &&function, Args &&... args) |
Helper factory function to make StaticThread object with partially deduced template arguments. More... | |
template<size_t StackSize, bool CanReceiveSignals = {}, size_t QueuedSignals = {}, size_t SignalActions = {}, typename Function , typename... Args> | |
StaticThread< StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args... > | distortos::makeStaticThread (const uint8_t priority, Function &&function, Args &&... args) |
Helper factory function to make StaticThread object with partially deduced template arguments. More... | |
template<size_t StackSize, bool CanReceiveSignals = {}, size_t QueuedSignals = {}, size_t SignalActions = {}, typename Function , typename... Args> | |
StaticThread< StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args... > | distortos::makeAndStartStaticThread (const uint8_t priority, const SchedulingPolicy schedulingPolicy, Function &&function, Args &&... args) |
Helper factory function to make and start StaticThread object with partially deduced template arguments. More... | |
template<size_t StackSize, bool CanReceiveSignals = {}, size_t QueuedSignals = {}, size_t SignalActions = {}, typename Function , typename... Args> | |
StaticThread< StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args... > | distortos::makeAndStartStaticThread (const uint8_t priority, Function &&function, Args &&... args) |
Helper factory function to make and start StaticThread object with partially deduced template arguments. More... | |
int | distortos::ThisThread::detach () |
Detaches calling (current) thread. More... | |
void | distortos::ThisThread::exit () |
Exits calling (current) thread. More... | |
Thread & | distortos::ThisThread::get () |
uint8_t | distortos::ThisThread::getEffectivePriority () |
ThreadIdentifier | distortos::ThisThread::getIdentifier () |
uint8_t | distortos::ThisThread::getPriority () |
SchedulingPolicy | distortos::ThisThread::getSchedulingPolicy () |
size_t | distortos::ThisThread::getStackHighWaterMark () |
size_t | distortos::ThisThread::getStackSize () |
void | distortos::ThisThread::setPriority (const uint8_t priority, const bool alwaysBehind) |
void | distortos::ThisThread::setSchedulingPolicy (const SchedulingPolicy schedulingPolicy) |
int | distortos::ThisThread::sleepFor (TickClock::duration duration) |
Makes the calling (current) thread sleep for at least given duration. More... | |
template<typename Rep , typename Period > | |
int | distortos::ThisThread::sleepFor (const std::chrono::duration< Rep, Period > duration) |
Makes the calling (current) thread sleep for at least given duration. More... | |
int | distortos::ThisThread::sleepUntil (TickClock::time_point timePoint) |
Makes the calling (current) thread sleep until some time point is reached. More... | |
template<typename Duration > | |
int | distortos::ThisThread::sleepUntil (const std::chrono::time_point< TickClock, Duration > timePoint) |
Makes the calling (current) thread sleep until some time point is reached. More... | |
void | distortos::ThisThread::yield () |
Yields time slot of the scheduler to next thread. More... | |
Threads-related API of distortos.
|
strong |
|
strong |
state of the thread
Enumerator | |
---|---|
created | state in which thread is created, before being added to Scheduler |
runnable | thread is runnable |
terminated | thread is terminated |
sleeping | thread is sleeping |
blockedOnSemaphore | thread is blocked on Semaphore |
suspended | thread is suspended |
blockedOnMutex | thread is blocked on Mutex |
blockedOnConditionVariable | thread is blocked on ConditionVariable |
waitingForSignal | thread is waiting for signal |
detached | internal thread object was detached |
int distortos::ThisThread::detach | ( | ) |
Detaches calling (current) thread.
Similar to std::thread::detach() - http://en.cppreference.com/w/cpp/thread/thread/detach Similar to POSIX pthread_detach() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_detach.html
Detaches calling (current) thread from its Thread object, allowing execution to continue independently. All resources allocated for the thread will be deallocated when the thread terminates.
void distortos::ThisThread::exit | ( | ) |
Exits calling (current) thread.
Similar to POSIX pthread_exit() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_exit.html
Thread & distortos::ThisThread::get | ( | ) |
uint8_t distortos::ThisThread::getEffectivePriority | ( | ) |
ThreadIdentifier distortos::ThisThread::getIdentifier | ( | ) |
uint8_t distortos::ThisThread::getPriority | ( | ) |
SchedulingPolicy distortos::ThisThread::getSchedulingPolicy | ( | ) |
size_t distortos::ThisThread::getStackHighWaterMark | ( | ) |
size_t distortos::ThisThread::getStackSize | ( | ) |
DynamicThread distortos::makeAndStartDynamicThread | ( | const size_t | stackSize, |
const bool | canReceiveSignals, | ||
const size_t | queuedSignals, | ||
const size_t | signalActions, | ||
const uint8_t | priority, | ||
const SchedulingPolicy | schedulingPolicy, | ||
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make and start DynamicThread object.
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | stackSize | is the size of stack, bytes |
[in] | canReceiveSignals | selects whether reception of signals is enabled (true) or disabled (false) for this thread |
[in] | queuedSignals | is the max number of queued signals for this thread, relevant only if canReceiveSignals == true, 0 to disable queuing of signals for this thread |
[in] | signalActions | is the max number of different SignalAction objects for this thread, relevant only if canReceiveSignals == true, 0 to disable catching of signals for this thread |
[in] | priority | is the thread's priority, 0 - lowest, UINT8_MAX - highest |
[in] | schedulingPolicy | is the scheduling policy of the thread |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
DynamicThread distortos::makeAndStartDynamicThread | ( | const DynamicThreadParameters | parameters, |
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make and start DynamicThread object.
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | parameters | is a DynamicThreadParameters struct with thread parameters |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
StaticThread<StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args...> distortos::makeAndStartStaticThread | ( | const uint8_t | priority, |
const SchedulingPolicy | schedulingPolicy, | ||
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make and start StaticThread object with partially deduced template arguments.
StackSize | is the size of stack, bytes |
CanReceiveSignals | selects whether reception of signals is enabled (true) or disabled (false) for this thread |
QueuedSignals | is the max number of queued signals for this thread, relevant only if CanReceiveSignals == true, 0 to disable queuing of signals for this thread |
SignalActions | is the max number of different SignalAction objects for this thread, relevant only if CanReceiveSignals == true, 0 to disable catching of signals for this thread |
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | priority | is the thread's priority, 0 - lowest, UINT8_MAX - highest |
[in] | schedulingPolicy | is the scheduling policy of the thread |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
StaticThread<StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args...> distortos::makeAndStartStaticThread | ( | const uint8_t | priority, |
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make and start StaticThread object with partially deduced template arguments.
StackSize | is the size of stack, bytes |
CanReceiveSignals | selects whether reception of signals is enabled (true) or disabled (false) for this thread |
QueuedSignals | is the max number of queued signals for this thread, relevant only if CanReceiveSignals == true, 0 to disable queuing of signals for this thread |
SignalActions | is the max number of different SignalAction objects for this thread, relevant only if CanReceiveSignals == true, 0 to disable catching of signals for this thread |
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | priority | is the thread's priority, 0 - lowest, UINT8_MAX - highest |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
DynamicThread distortos::makeDynamicThread | ( | const size_t | stackSize, |
const bool | canReceiveSignals, | ||
const size_t | queuedSignals, | ||
const size_t | signalActions, | ||
const uint8_t | priority, | ||
const SchedulingPolicy | schedulingPolicy, | ||
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make DynamicThread object.
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | stackSize | is the size of stack, bytes |
[in] | canReceiveSignals | selects whether reception of signals is enabled (true) or disabled (false) for this thread |
[in] | queuedSignals | is the max number of queued signals for this thread, relevant only if canReceiveSignals == true, 0 to disable queuing of signals for this thread |
[in] | signalActions | is the max number of different SignalAction objects for this thread, relevant only if canReceiveSignals == true, 0 to disable catching of signals for this thread |
[in] | priority | is the thread's priority, 0 - lowest, UINT8_MAX - highest |
[in] | schedulingPolicy | is the scheduling policy of the thread |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
DynamicThread distortos::makeDynamicThread | ( | const DynamicThreadParameters | parameters, |
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make DynamicThread object.
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | parameters | is a DynamicThreadParameters struct with thread parameters |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
StaticThread<StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args...> distortos::makeStaticThread | ( | const uint8_t | priority, |
const SchedulingPolicy | schedulingPolicy, | ||
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make StaticThread object with partially deduced template arguments.
StackSize | is the size of stack, bytes |
CanReceiveSignals | selects whether reception of signals is enabled (true) or disabled (false) for this thread |
QueuedSignals | is the max number of queued signals for this thread, relevant only if CanReceiveSignals == true, 0 to disable queuing of signals for this thread |
SignalActions | is the max number of different SignalAction objects for this thread, relevant only if CanReceiveSignals == true, 0 to disable catching of signals for this thread |
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | priority | is the thread's priority, 0 - lowest, UINT8_MAX - highest |
[in] | schedulingPolicy | is the scheduling policy of the thread |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
StaticThread<StackSize, CanReceiveSignals, QueuedSignals, SignalActions, Function, Args...> distortos::makeStaticThread | ( | const uint8_t | priority, |
Function && | function, | ||
Args &&... | args | ||
) |
Helper factory function to make StaticThread object with partially deduced template arguments.
StackSize | is the size of stack, bytes |
CanReceiveSignals | selects whether reception of signals is enabled (true) or disabled (false) for this thread |
QueuedSignals | is the max number of queued signals for this thread, relevant only if CanReceiveSignals == true, 0 to disable queuing of signals for this thread |
SignalActions | is the max number of different SignalAction objects for this thread, relevant only if CanReceiveSignals == true, 0 to disable catching of signals for this thread |
Function | is the function that will be executed |
Args | are the arguments for Function |
[in] | priority | is the thread's priority, 0 - lowest, UINT8_MAX - highest |
[in] | function | is a function that will be executed in separate thread |
[in] | args | are arguments for function |
void distortos::ThisThread::setPriority | ( | uint8_t | priority, |
bool | alwaysBehind = {} |
||
) |
Changes priority of calling (current) thread.
[in] | priority | is the new priority for thread |
[in] | alwaysBehind | selects the method of ordering when lowering the priority
|
void distortos::ThisThread::setSchedulingPolicy | ( | SchedulingPolicy | schedulingPolicy | ) |
param [in] schedulingPolicy is the new scheduling policy of calling (current) thread
int distortos::ThisThread::sleepFor | ( | TickClock::duration | duration | ) |
Makes the calling (current) thread sleep for at least given duration.
Current thread's state is changed to "sleeping".
[in] | duration | is the duration after which the thread will be woken |
int distortos::ThisThread::sleepFor | ( | const std::chrono::duration< Rep, Period > | duration | ) |
Makes the calling (current) thread sleep for at least given duration.
Current thread's state is changed to "sleeping".
Rep | is type of tick counter |
Period | is std::ratio type representing the tick period of the clock, seconds |
[in] | duration | is the duration after which the thread will be woken |
int distortos::ThisThread::sleepUntil | ( | TickClock::time_point | timePoint | ) |
Makes the calling (current) thread sleep until some time point is reached.
Current thread's state is changed to "sleeping".
[in] | timePoint | is the time point at which the thread will be woken |
int distortos::ThisThread::sleepUntil | ( | const std::chrono::time_point< TickClock, Duration > | timePoint | ) |
Makes the calling (current) thread sleep until some time point is reached.
Current thread's state is changed to "sleeping".
Duration | is a std::chrono::duration type used to measure duration |
[in] | timePoint | is the time point at which the thread will be woken |
void distortos::ThisThread::yield | ( | ) |
Yields time slot of the scheduler to next thread.