distortos  v0.5.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 <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::ThreadCommon
using StackStorageUniquePointer = internal::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::ThreadCommon
 ThreadCommon (internal::Stack &&stack, uint8_t priority, SchedulingPolicy schedulingPolicy, internal::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
 
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 ()=0
 Thread's destructor. More...
 

Static Private Member Functions

static void run (Thread &thread)
 Thread's "run" function. 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...
 

Additional Inherited Members

- Protected Member Functions inherited from distortos::ThreadCommon
internal::ThreadControlBlockgetThreadControlBlock ()
 
const internal::ThreadControlBlockgetThreadControlBlock () const
 
int startInternal (void(&runFunction)(Thread &), void(*preTerminationHookFunction)(Thread &), void(&terminationHookFunction)(Thread &))
 Starts the thread. More...
 
- Static Protected Member Functions inherited from distortos::ThreadCommon
static void terminationHook (Thread &thread)
 Termination hook function of thread. 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
Here is the caller graph for this function:

Member Function Documentation

◆ run()

template<size_t StackSize, typename Function, typename... Args>
static void distortos::internal::StaticThreadBase< StackSize, Function, Args >::run ( Thread thread)
inlinestaticprivate

Thread's "run" function.

Executes bound function object.

Parameters
[in]threadis a reference to Thread object, this must be StaticThreadBase!
Here is the caller graph for this function:

◆ 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 "New" 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 + CONFIG_ARCHITECTURE_STACK_ALIGNMENT - 1) /
CONFIG_ARCHITECTURE_STACK_ALIGNMENT * CONFIG_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: