distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::internal::StaticThreadBase< StackSize, Function, Args > Class Template Reference

StaticThreadBase class is a templated common base for StaticThread. More...

#include "distortos/StaticThread.hpp"

Inheritance diagram for distortos::internal::StaticThreadBase< StackSize, Function, Args >:
[legend]
Collaboration diagram for distortos::internal::StaticThreadBase< StackSize, Function, Args >:
[legend]

Public Types

using Base = UndetachableThread
 base of StaticThreadBase More...
 
- Public Types inherited from distortos::internal::ThreadCommon
using StackStorageUniquePointer = Stack::StorageUniquePointer
 unique_ptr (with deleter) to storage for stack More...
 

Public Member Functions

 StaticThreadBase (const uint8_t priority, const SchedulingPolicy schedulingPolicy, SignalsReceiver *const signalsReceiver, Function &&function, Args &&... args)
 StaticThreadBase's constructor. More...
 
 StaticThreadBase (const StaticThreadBase &)=delete
 
 StaticThreadBase (StaticThreadBase &&)=default
 
const StaticThreadBaseoperator= (const StaticThreadBase &)=delete
 
StaticThreadBaseoperator= (StaticThreadBase &&)=delete
 
int start ()
 Starts the thread. More...
 
- Public Member Functions inherited from distortos::UndetachableThread
int detach () override
 Detaches the thread. More...
 
- Public Member Functions inherited from distortos::internal::ThreadCommon
 ThreadCommon (Stack &&stack, uint8_t priority, SchedulingPolicy schedulingPolicy, ThreadGroupControlBlock *threadGroupControlBlock, SignalsReceiver *signalsReceiver)
 ThreadCommon's constructor. More...
 
 ~ThreadCommon () override
 ThreadCommon's destructor. More...
 
int generateSignal (uint8_t signalNumber) override
 Generates signal for thread. More...
 
uint8_t getEffectivePriority () const override
 
ThreadIdentifier getIdentifier () const override
 
SignalSet getPendingSignalSet () const override
 Gets set of currently pending signals. More...
 
uint8_t getPriority () const override
 
SchedulingPolicy getSchedulingPolicy () const override
 
size_t getStackHighWaterMark () const override
 
size_t getStackSize () const override
 
ThreadState getState () const override
 
int join () override
 Waits for thread termination. More...
 
int queueSignal (uint8_t signalNumber, sigval value) override
 Queues signal for thread. More...
 
void setPriority (uint8_t priority, bool alwaysBehind={}) override
 Changes priority of thread. More...
 
void setSchedulingPolicy (SchedulingPolicy schedulingPolicy) override
 
 ThreadCommon (const ThreadCommon &)=delete
 
 ThreadCommon (ThreadCommon &&)=default
 
const ThreadCommonoperator= (const ThreadCommon &)=delete
 
ThreadCommonoperator= (ThreadCommon &&)=delete
 
- Public Member Functions inherited from distortos::Thread
virtual ~Thread ()=default
 Thread's destructor. More...
 

Protected Member Functions

void run () override
 Thread's "run" function. More...
 
- Protected Member Functions inherited from distortos::internal::ThreadCommon
void exit0Hook () override
 Thread's "exit 0" hook function. More...
 
void exit1Hook () override
 Thread's "exit 1" hook function. More...
 
ThreadControlBlockgetThreadControlBlock ()
 
const ThreadControlBlockgetThreadControlBlock () const
 
int startInternal ()
 Starts the thread. More...
 

Private Attributes

std::aligned_storage< adjustedStackSize+internal::stackGuardSize >::type stack_
 stack buffer More...
 
decltype(std::bind(std::declval< Function >(), std::declval< Args >()...)) boundFunction_
 bound function object More...
 

Static Private Attributes

static constexpr size_t adjustedStackSize
 size of stack adjusted to alignment requirements, bytes More...
 

Detailed Description

template<size_t StackSize, typename Function, typename... Args>
class distortos::internal::StaticThreadBase< StackSize, Function, Args >

StaticThreadBase class is a templated common base for StaticThread.

Template Parameters
StackSizeis the size of stack, bytes
Functionis the function that will be executed in separate thread
Argsare the arguments for Function

Member Typedef Documentation

◆ Base

template<size_t StackSize, typename Function, typename... Args>
using distortos::internal::StaticThreadBase< StackSize, Function, Args >::Base = UndetachableThread

Constructor & Destructor Documentation

◆ StaticThreadBase()

template<size_t StackSize, typename Function, typename... Args>
distortos::internal::StaticThreadBase< StackSize, Function, Args >::StaticThreadBase ( const uint8_t  priority,
const SchedulingPolicy  schedulingPolicy,
SignalsReceiver *const  signalsReceiver,
Function &&  function,
Args &&...  args 
)
inline

StaticThreadBase's constructor.

Parameters
[in]priorityis the thread's priority, 0 - lowest, UINT8_MAX - highest
[in]schedulingPolicyis the scheduling policy of the thread
[in]signalsReceiveris a pointer to SignalsReceiver object for this thread, nullptr to disable reception of signals for this thread
[in]functionis a function that will be executed in separate thread
[in]argsare arguments for function

Member Function Documentation

◆ run()

template<size_t StackSize, typename Function, typename... Args>
void distortos::internal::StaticThreadBase< StackSize, Function, Args >::run ( )
inlineoverrideprotectedvirtual

Thread's "run" function.

Executes bound function object.

Implements distortos::internal::RunnableThread.

◆ start()

template<size_t StackSize, typename Function, typename... Args>
int distortos::internal::StaticThreadBase< StackSize, Function, Args >::start ( )
inline

Starts the thread.

This operation can be performed on threads in "created" state only.

Returns
0 on success, error code otherwise:

Member Data Documentation

◆ adjustedStackSize

template<size_t StackSize, typename Function, typename... Args>
constexpr size_t distortos::internal::StaticThreadBase< StackSize, Function, Args >::adjustedStackSize
staticprivate
Initial value:
{(StackSize + DISTORTOS_ARCHITECTURE_STACK_ALIGNMENT - 1) /
DISTORTOS_ARCHITECTURE_STACK_ALIGNMENT * DISTORTOS_ARCHITECTURE_STACK_ALIGNMENT}

size of stack adjusted to alignment requirements, bytes

◆ boundFunction_

template<size_t StackSize, typename Function, typename... Args>
decltype(std::bind(std::declval<Function>(), std::declval<Args>()...)) distortos::internal::StaticThreadBase< StackSize, Function, Args >::boundFunction_
private

bound function object

◆ stack_

template<size_t StackSize, typename Function, typename... Args>
std::aligned_storage<adjustedStackSize + internal::stackGuardSize>::type distortos::internal::StaticThreadBase< StackSize, Function, Args >::stack_
private

stack buffer


The documentation for this class was generated from the following file: