rad 6.2.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
rad::ThreadBaseActivity Class Referenceabstract

#include <activity.hpp>

Inheritance diagram for rad::ThreadBaseActivity:
scxml4cpp::Activity rad::PthreadActivity rad::ThreadActivity MyTestDoActivityPthread rad::ConfigurablePthreadActivity MyTestDoActivity exmalserver::ActivityMoving rad::ActivityUpdateOldb rad::ConfigurableActivity server::ActivityMoving exciiserver::ActivityMoving exciiserver::ActivityMovingDds rad::utest::Activity

Public Member Functions

 ThreadBaseActivity (ThreadBaseActivity const &)=delete
 
void start (scxml4cpp::Context *c) override
 
void stop (scxml4cpp::Context *c) override
 
virtual pthread_t GetNativeHandle () const =0
 
bool IsStopRequested () const
 
virtual bool IsThreadJoined () const =0
 
- Public Member Functions inherited from scxml4cpp::Activity
 Activity (const std::string &id)
 
virtual ~Activity ()
 
std::string getId () const
 
void setId (const std::string &id)
 

Protected Member Functions

virtual void StartThread ()=0
 
virtual void JoinThread ()=0
 

Detailed Description

Base class for different implementations of threaded activities.

It implements start(), stop() from scxml4cpp::Activity and provides IsStopRequested() which returns true if the activity implementation should stop and exit.

Implementations need to implement thread-specific methods:

This is a shared base for std::thread and pthread_t based threaded activities.

Note
that other perfectly valid options exist for interrupting the activity when it's time to stop. For example by using condition variables. This could be provided as a templated policy or a runtime provided implementation.
Attention
methods of this class are not thread safe with the only exception for IsStopRequested.

Constructor & Destructor Documentation

◆ ThreadBaseActivity()

rad::ThreadBaseActivity::ThreadBaseActivity ( ThreadBaseActivity const & )
delete

Member Function Documentation

◆ GetNativeHandle()

virtual pthread_t rad::ThreadBaseActivity::GetNativeHandle ( ) const
pure virtual
Returns
Interface to obtain the native thread handle.

Implemented in rad::ThreadActivity, and rad::PthreadActivity.

◆ IsStopRequested()

bool rad::ThreadBaseActivity::IsStopRequested ( ) const
inline

Method used by child classes to check whether they should be stopping.

Returns
true if the activity should terminate, false otherwise.

◆ IsThreadJoined()

virtual bool rad::ThreadBaseActivity::IsThreadJoined ( ) const
pure virtual

Interface to be implemented by child classes to verify whether the thread is running or not.

Returns
true if the thread is not running, false otherwise.

Implemented in rad::ThreadActivity, and rad::PthreadActivity.

◆ JoinThread()

virtual void rad::ThreadBaseActivity::JoinThread ( )
protectedpure virtual

◆ start()

void rad::ThreadBaseActivity::start ( scxml4cpp::Context * c)
overridevirtual

Start the thread implementing the activity.

Parameters
cSCXML context.
Note
Will stop() activity if it's running.

Implements scxml4cpp::Activity.

◆ StartThread()

virtual void rad::ThreadBaseActivity::StartThread ( )
protectedpure virtual

◆ stop()

void rad::ThreadBaseActivity::stop ( scxml4cpp::Context * c)
overridevirtual

Stop the thread implementing the activity.

Parameters
cSCXML context.

Implements scxml4cpp::Activity.


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