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

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

#include <StaticThread.hpp>

Inheritance diagram for distortos::internal::StaticThreadBase< Function, Args >:
[legend]
Collaboration diagram for distortos::internal::StaticThreadBase< 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 (StackStorageUniquePointer &&stackStorageUniquePointer, const size_t size, 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 Protected Attributes

static constexpr size_t stackGuardSize_
 size of "stack guard", bytes More...
 

Static Private Member Functions

static void run (Thread &thread)
 Thread's "run" function. More...
 

Private Attributes

decltype(std::bind(std::declval< Function >(), std::declval< Args >()...)) boundFunction_
 bound function object 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<typename Function, typename... Args>
class distortos::internal::StaticThreadBase< Function, Args >

StaticThreadBase class is a templated common base for StaticThread.

Template Parameters
Functionis the function that will be executed in separate thread
Argsare the arguments for Function

Member Typedef Documentation

◆ Base

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

Constructor & Destructor Documentation

◆ StaticThreadBase()

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

StaticThreadBase's constructor.

Parameters
[in]stackStorageUniquePointeris a rvalue reference to StackStorageUniquePointer with storage for stack (size bytes long) and appropriate deleter
[in]sizeis the size of stack's storage, bytes
[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<typename Function, typename... Args>
static void distortos::internal::StaticThreadBase< 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<typename Function, typename... Args>
int distortos::internal::StaticThreadBase< 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

◆ boundFunction_

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

bound function object

◆ stackGuardSize_

template<typename Function, typename... Args>
constexpr size_t distortos::internal::StaticThreadBase< Function, Args >::stackGuardSize_
staticprotected
Initial value:
{(CONFIG_STACK_GUARD_SIZE + CONFIG_ARCHITECTURE_STACK_ALIGNMENT - 1) /
CONFIG_ARCHITECTURE_STACK_ALIGNMENT * CONFIG_ARCHITECTURE_STACK_ALIGNMENT}

size of "stack guard", bytes


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