rad 6.2.0
|
#include <activity.hpp>
Public Member Functions | |
ThreadActivity (const ThreadActivity &)=delete | |
ThreadActivity & | operator= (const ThreadActivity &)=delete |
virtual void | Run ()=0 |
pthread_t | GetNativeHandle () const override |
bool | IsThreadJoined () const override |
ThreadBaseActivity (ThreadBaseActivity const &)=delete | |
![]() | |
ThreadBaseActivity (ThreadBaseActivity const &)=delete | |
void | start (scxml4cpp::Context *c) override |
void | stop (scxml4cpp::Context *c) override |
bool | IsStopRequested () const |
![]() | |
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 |
std::string | GetPthreadName () |
int | SetPthreadName (const std::string &name) |
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 ... } } };
|
delete |
|
overridevirtual |
TODO review whether 'const' is needed.
Implements rad::ThreadBaseActivity.
|
protected |
This method is similar to GetName() but it uses the platform specific pthread_self() function instead of the platform independent native_handle().
This avoid data race conditions between the main thread that started the activity and the activity thread itself that tries to get/set its name. In fact when the activity is started the m_thread attribute is assigned via a swap of the std::thread. This std::thread seems to be read also by native_handle() creating a possible data race condition.
|
overridevirtual |
Implements rad::ThreadBaseActivity.
|
overrideprotectedvirtual |
Helper method to stop a do-activity thread.
Implements rad::ThreadBaseActivity.
|
delete |
|
pure virtual |
Interface to be implemented by child classes to implement the activity thread.
Implemented in rad::utest::Activity, exciiserver::ActivityMoving, exciiserver::ActivityMovingDds, exmalserver::ActivityMoving, server::ActivityMoving, rad::ActivityUpdateOldb, and MyTestDoActivity.
|
protected |
This method is similar to SetName() but it uses the platform specific pthread_self() function instead of the platform independent native_handle().
See GetPthreadName() for a full explanation of the advantages vs SetName().
name | Name for the thread. |
|
overrideprotectedvirtual |
Helper method to start a do-activity thread.
Implements rad::ThreadBaseActivity.
|
delete |