distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::Thread Class Referenceabstract

Thread class is a pure abstract interface for threads. More...

#include "distortos/Thread.hpp"

Inheritance diagram for distortos::Thread:
[legend]

Public Member Functions

virtual ~Thread ()=default
 Thread's destructor. More...
 
virtual int detach ()=0
 Detaches the thread. More...
 
virtual int generateSignal (uint8_t signalNumber)=0
 Generates signal for thread. More...
 
virtual uint8_t getEffectivePriority () const =0
 
virtual ThreadIdentifier getIdentifier () const =0
 
virtual SignalSet getPendingSignalSet () const =0
 Gets set of currently pending signals. More...
 
virtual uint8_t getPriority () const =0
 
virtual SchedulingPolicy getSchedulingPolicy () const =0
 
virtual size_t getStackHighWaterMark () const =0
 
virtual size_t getStackSize () const =0
 
virtual ThreadState getState () const =0
 
virtual int join ()=0
 Waits for thread termination. More...
 
virtual int queueSignal (uint8_t signalNumber, sigval value)=0
 Queues signal for thread. More...
 
virtual void setPriority (uint8_t priority, bool alwaysBehind={})=0
 Changes priority of thread. More...
 
virtual void setSchedulingPolicy (SchedulingPolicy schedulingPolicy)=0
 

Detailed Description

Thread class is a pure abstract interface for threads.

Constructor & Destructor Documentation

◆ ~Thread()

virtual distortos::Thread::~Thread ( )
virtualdefault

Thread's destructor.

Member Function Documentation

◆ detach()

virtual int distortos::Thread::detach ( )
pure virtual

Detaches the 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 the executing thread from the Thread object, allowing execution to continue independently. All resources allocated for the thread will be deallocated when the thread terminates.

Returns
0 on success, error code otherwise:
  • EINVAL - this thread is already detached;
  • ENOTSUP - this thread cannot be detached;

Implemented in distortos::internal::DynamicThreadBase, distortos::DynamicThread, and distortos::UndetachableThread.

Here is the caller graph for this function:

◆ getEffectivePriority()

virtual uint8_t distortos::Thread::getEffectivePriority ( ) const
pure virtual
Returns
effective priority of thread

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

◆ getIdentifier()

virtual ThreadIdentifier distortos::Thread::getIdentifier ( ) const
pure virtual
Returns
identifier of thread, default-constructed ThreadIdentifier if this object doesn't represent a valid thread of execution (e.g. after the thread is detached)

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

◆ getPriority()

virtual uint8_t distortos::Thread::getPriority ( ) const
pure virtual
Returns
priority of thread

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

◆ getSchedulingPolicy()

virtual SchedulingPolicy distortos::Thread::getSchedulingPolicy ( ) const
pure virtual
Returns
scheduling policy of the thread

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

◆ getStackHighWaterMark()

virtual size_t distortos::Thread::getStackHighWaterMark ( ) const
pure virtual
Returns
"high water mark" (max usage) of thread's stack, bytes

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

Here is the caller graph for this function:

◆ getStackSize()

virtual size_t distortos::Thread::getStackSize ( ) const
pure virtual
Returns
size of thread's stack, bytes

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

Here is the caller graph for this function:

◆ getState()

virtual ThreadState distortos::Thread::getState ( ) const
pure virtual
Returns
current state of thread

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

◆ setPriority()

virtual void distortos::Thread::setPriority ( uint8_t  priority,
bool  alwaysBehind = {} 
)
pure virtual

Changes priority of thread.

If the priority really changes, the position in the thread list is adjusted and context switch may be requested.

Parameters
[in]priorityis the new priority of thread
[in]alwaysBehindselects the method of ordering when lowering the priority
  • false - the thread is moved to the head of the group of threads with the new priority (default),
  • true - the thread is moved to the tail of the group of threads with the new priority.

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

◆ setSchedulingPolicy()

virtual void distortos::Thread::setSchedulingPolicy ( SchedulingPolicy  schedulingPolicy)
pure virtual

param [in] schedulingPolicy is the new scheduling policy of the thread

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.


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