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

#include <pthreadActivity.hpp>

Inheritance diagram for rad::PthreadActivity:
rad::ThreadBaseActivity scxml4cpp::Activity MyTestDoActivityPthread rad::ConfigurablePthreadActivity

Public Member Functions

 PthreadActivity (const std::string &id, const int cpu=-1, const int priotity=-1)
 
virtual ~PthreadActivity ()
 
virtual void Run ()=0
 
std::string GetName ()
 
int SetName (const std::string &name)
 
int GetCPU () const
 
int GetConfiguredCPU () const
 
void SetConfiguredCPU (const int cpu)
 
int GetPriority ()
 
int GetConfiguredPriority () const
 
void SetConfiguredPriority (const int priority)
 
pthread_t GetNativeHandle () const override
 
 PthreadActivity (const PthreadActivity &)=delete
 
PthreadActivityoperator= (const PthreadActivity &)=delete
 Disable copy constructor.
 
- 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
 Disable assignment operator.
 
void JoinThread () override
 
bool IsThreadJoined () const override
 

Detailed Description

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

Todo

: move to std::threads

: add common base class

: add fiber based activity

Constructor & Destructor Documentation

◆ PthreadActivity() [1/2]

rad::PthreadActivity::PthreadActivity ( const std::string & id,
const int cpu = -1,
const int priority = -1 )
explicit

Constructor for the PthreadActivity class.

Parameters
[in]idIdentifier of the do-activity.
[in]cpuCore where to run the thread associated to the activity.
[in]priorityPriority of the thread associated to the activity.

◆ ~PthreadActivity()

rad::PthreadActivity::~PthreadActivity ( )
virtual

Destructor for the PthreadActivity class.

◆ PthreadActivity() [2/2]

rad::PthreadActivity::PthreadActivity ( const PthreadActivity & )
delete

Member Function Documentation

◆ GetConfiguredCPU()

int rad::PthreadActivity::GetConfiguredCPU ( ) const
Returns
the CPU on which the thread was configured to run.

◆ GetConfiguredPriority()

int rad::PthreadActivity::GetConfiguredPriority ( ) const
Returns
the configured priority for this thread.

◆ GetCPU()

int rad::PthreadActivity::GetCPU ( ) const
Returns
the CPU on which the thread is running. It has to be invoked from the running method, otherwise it returns the CPU where the main thread is running.

◆ GetName()

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

◆ GetNativeHandle()

pthread_t rad::PthreadActivity::GetNativeHandle ( ) const
overridevirtual
Precondition
Activity must have been started.
Returns
The posix handle to the thread.

Implements rad::ThreadBaseActivity.

◆ GetPriority()

int rad::PthreadActivity::GetPriority ( )
Returns
the priority of this thread (> 0) or the error code (< 0).

◆ IsThreadJoined()

bool rad::PthreadActivity::IsThreadJoined ( ) const
overrideprotectedvirtual

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.

Implements rad::ThreadBaseActivity.

◆ JoinThread()

void rad::PthreadActivity::JoinThread ( )
overrideprotectedvirtual

Helper method to stop a do-activity thread.

Implements rad::ThreadBaseActivity.

◆ operator=()

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

Disable copy constructor.

◆ Run()

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

Implemented in MyTestDoActivityPthread.

◆ SetConfiguredCPU()

void rad::PthreadActivity::SetConfiguredCPU ( const int cpu)

Configure the CPU on which the thread should be executed.

Parameters
[in]cpuNew core identifier.

◆ SetConfiguredPriority()

void rad::PthreadActivity::SetConfiguredPriority ( const int priority)

Configure the priority for this thread.

Parameters
[in]priorityNew thread priority.

◆ SetName()

int rad::PthreadActivity::SetName ( const std::string & name)
Parameters
[in]namefor the thread.
Returns
error code or 0 if successful.

◆ StartThread()

void rad::PthreadActivity::StartThread ( )
overrideprotectedvirtual

Disable assignment operator.

Helper method to start a do-activity thread.

Implements rad::ThreadBaseActivity.


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