ifw-ccf 5.0.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
ifw::ccf::mptk::Thread Class Reference

IFW CTD Multiprocessing Toolkit Thread base class. More...

#include <thread.hpp>

Inheritance diagram for ifw::ccf::mptk::Thread:
TestThread TestThread1 ifw::ccf::control::AcqThread ifw::ccf::control::MonitorThread ifw::ccf::control::ProcThread ifw::ccf::control::PubThread

Public Types

enum  ThreadExecControl { THREAD_EXEC_STOPPED = 1 , THREAD_EXEC_RUNNING , THREAD_EXEC_PAUSED }
 Thread execution control/status. More...
 

Public Member Functions

 Thread (const std::string &thread_name, MessageBus &message_bus, const double period=0.1)
 Constructor method, setting up the internal members.
 
virtual ~Thread ()
 
void SetPriority (const int prio=-1)
 If invoked, it will run the thread in real-time mode with the given priority [0; 99].
 
std::string GetName () const
 Return the thread Name.
 
void Run ()
 Method to invoke the user provided business logic of the thread. The method executes internally a loop.
 
virtual void UserLogic ()
 User provided business logic. The UserLogic method need not execute an internal loop. It is taken care of by the Control() method. Instead the UserLogic() method should (normally) execute it business logic, and return control to the Control() method, which will take of the thread management.
 
void Start ()
 Start the thread execution.
 
void Stop ()
 Stop the thread execution.
 
void Pause ()
 Pause the thread execution.
 
void Continue ()
 Continue a paused thread execution.
 
double GetDrift () const
 
bool GetExecFlag ()
 Check the Thread Execution Flag. The Thread Execution Flag shall be called regularly in the thread, at least during every internal cycle (of LogicUser()). The behavior is as follows: THREAD_EXEC_RUNNING: Return immediately with true. THREAD_EXEC_PAUSED: Wait internally for flag to change to THREAD_EXEC_RUN/_STOP. TRHEAD_EXEC_STOPPED: Return immediately with false. Thread LogicUser() shall return.
 
ThreadExecControl GetExecFlag () const
 Return the value of the Thread Execution Flag.
 
bool Terminated ()
 Returns true if thread no longer running.
 
MessageBusMsgBus ()
 Get acces to the MessageBus associated with this thread object.
 
std::string ToString () const
 Generate ASCII output providing a status of the object.
 

Static Public Attributes

static std::map< std::string, Thread * > s_thread_registry
 

Detailed Description

IFW CTD Multiprocessing Toolkit Thread base class.

All threads to be executed in the MPTK environment, shall be derived from this class. It provides a scheduling mechanism, which executes the context specific user logic at a specified rate.

Member Enumeration Documentation

◆ ThreadExecControl

Thread execution control/status.

Enumerator
THREAD_EXEC_STOPPED 
THREAD_EXEC_RUNNING 
THREAD_EXEC_PAUSED 

Constructor & Destructor Documentation

◆ Thread()

ifw::ccf::mptk::Thread::Thread ( const std::string & thread_name,
MessageBus & message_bus,
const double period = 0.1 )

Constructor method, setting up the internal members.

Parameters
thread_nameThe ID of the thread.
message_busReference to MPTK Message Bus object to use.
periodPeriod (s) (soft realtime) execution time for the thread loop (if relevant).

◆ ~Thread()

ifw::ccf::mptk::Thread::~Thread ( )
virtual

Member Function Documentation

◆ Continue()

void ifw::ccf::mptk::Thread::Continue ( )

Continue a paused thread execution.

◆ GetDrift()

double ifw::ccf::mptk::Thread::GetDrift ( ) const

◆ GetExecFlag() [1/2]

bool ifw::ccf::mptk::Thread::GetExecFlag ( )

Check the Thread Execution Flag. The Thread Execution Flag shall be called regularly in the thread, at least during every internal cycle (of LogicUser()). The behavior is as follows: THREAD_EXEC_RUNNING: Return immediately with true. THREAD_EXEC_PAUSED: Wait internally for flag to change to THREAD_EXEC_RUN/_STOP. TRHEAD_EXEC_STOPPED: Return immediately with false. Thread LogicUser() shall return.

◆ GetExecFlag() [2/2]

Thread::ThreadExecControl ifw::ccf::mptk::Thread::GetExecFlag ( ) const

Return the value of the Thread Execution Flag.

◆ GetName()

std::string ifw::ccf::mptk::Thread::GetName ( ) const

Return the thread Name.

◆ MsgBus()

MessageBus & ifw::ccf::mptk::Thread::MsgBus ( )

Get acces to the MessageBus associated with this thread object.

◆ Pause()

void ifw::ccf::mptk::Thread::Pause ( )

Pause the thread execution.

◆ Run()

void ifw::ccf::mptk::Thread::Run ( )

Method to invoke the user provided business logic of the thread. The method executes internally a loop.

◆ SetPriority()

void ifw::ccf::mptk::Thread::SetPriority ( const int prio = -1)

If invoked, it will run the thread in real-time mode with the given priority [0; 99].

◆ Start()

void ifw::ccf::mptk::Thread::Start ( )

Start the thread execution.

◆ Stop()

void ifw::ccf::mptk::Thread::Stop ( )

Stop the thread execution.

◆ Terminated()

bool ifw::ccf::mptk::Thread::Terminated ( )

Returns true if thread no longer running.

◆ ToString()

std::string ifw::ccf::mptk::Thread::ToString ( ) const

Generate ASCII output providing a status of the object.

◆ UserLogic()

void ifw::ccf::mptk::Thread::UserLogic ( )
virtual

User provided business logic. The UserLogic method need not execute an internal loop. It is taken care of by the Control() method. Instead the UserLogic() method should (normally) execute it business logic, and return control to the Control() method, which will take of the thread management.

Reimplemented in ifw::ccf::control::AcqThread, ifw::ccf::control::MonitorThread, ifw::ccf::control::ProcThread, ifw::ccf::control::PubThread, TestThread, and TestThread1.

Member Data Documentation

◆ s_thread_registry

std::map< std::string, Thread * > ifw::ccf::mptk::Thread::s_thread_registry
static

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