rad  5.1.0
Public Member Functions | Protected Member Functions | List of all members
rad::ThreadActivity Class Referenceabstract

#include <activity.hpp>

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

Public Member Functions

 ThreadActivity (const ThreadActivity &)=delete
 
ThreadActivityoperator= (const ThreadActivity &)=delete
 
virtual void Run ()=0
 
pthread_t GetNativeHandle () const override
 
bool IsThreadJoined () const override
 
std::string GetName ()
 
int SetName (const std::string &name)
 
 ThreadBaseActivity (ThreadBaseActivity const &)=delete
 
- Public Member Functions inherited from rad::ThreadBaseActivity
 ThreadBaseActivity (ThreadBaseActivity const &)=delete
 
void start (scxml4cpp::Context *c) override
 
void stop (scxml4cpp::Context *c) override
 
bool IsStopRequested () const
 
- 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

void StartThread () override
 
void JoinThread () override
 

Detailed Description

This class is the base class for thread-based do-activities.

User should use IsStopRequested() to check for when to stop the activity.

Example implementation:

 class MyActivity : public ThreadActivity {
     void Run() override {
         while(!IsStopRequested()) {
             // do work
             ...
         }
     }
 };
Attention
methods of this class are not thread safe. It is assumed that the activity thread attributes cannot be modified by other threads. If thread safety is needed, the developer will subclass and add protection.

Constructor & Destructor Documentation

◆ ThreadActivity()

rad::ThreadActivity::ThreadActivity ( const ThreadActivity )
delete

Member Function Documentation

◆ GetName()

std::string rad::ThreadActivity::GetName ( )
Returns
The name of the do-activity thread.

◆ GetNativeHandle()

pthread_t rad::ThreadActivity::GetNativeHandle ( ) const
overridevirtual
Returns
A handle to the native thread implementation.

TODO review whether 'const' is needed.

Implements rad::ThreadBaseActivity.

◆ IsThreadJoined()

bool rad::ThreadActivity::IsThreadJoined ( ) const
overridevirtual
Returns
true if the thread is not running, false otherwise.

Implements rad::ThreadBaseActivity.

◆ JoinThread()

void rad::ThreadActivity::JoinThread ( )
overrideprotectedvirtual

Helper method to stop a do-activity thread.

Implements rad::ThreadBaseActivity.

◆ operator=()

ThreadActivity& rad::ThreadActivity::operator= ( const ThreadActivity )
delete

◆ Run()

virtual void rad::ThreadActivity::Run ( )
pure virtual

Interface to be implemented by child classes to implement the activity thread.

Implemented in MyTestDoActivity, rad::ActivityUpdateOldb, server::ActivityMoving, exmalserver::ActivityMoving, exciiserver::ActivityMoving, and rad::utest::Activity.

◆ SetName()

int rad::ThreadActivity::SetName ( const std::string &  name)

Set thread name.

Parameters
[in]namefor the thread. Maximum length is 15 characters (excluding null terminator).
Returns
error code or 0 if successful.

◆ StartThread()

void rad::ThreadActivity::StartThread ( )
overrideprotectedvirtual

Helper method to start a do-activity thread.

Implements rad::ThreadBaseActivity.

◆ ThreadBaseActivity()

rad::ThreadBaseActivity::ThreadBaseActivity
delete

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