PLCnext API Documentation  21.0.0.35466
Public Types | Public Member Functions | List of all members
Arp::System::Commons::Threading::WorkerThread Class Reference

Worker threads repeat the execution of the threaded code until Stop is called. More...

#include <WorkerThread.hpp>

Public Types

typedef delegate< void(void)> WorkDelegate
 The delegate of threads loop body. More...
 

Public Member Functions

template<class TInstance , class TFunction >
 WorkerThread (TInstance &instance, TFunction fn, int idleTime, const char *threadName)
 Constructs an WorkerThread instance for a class method. More...
 
template<class TInstance , class TFunction >
 WorkerThread (const TInstance &instance, TFunction fn, int idleTime, const char *threadName)
 Constructs an WorkerThread instance for a class method. More...
 
template<class TInstance , class TFunction >
 WorkerThread (TInstance *pInstance, TFunction fn, int idleTime, const char *threadName)
 Constructs an WorkerThread instance for a class method. More...
 
template<class TInstance , class TFunction >
 WorkerThread (const TInstance *pInstance, TFunction fn, int idleTime, const char *threadName)
 Constructs an WorkerThread instance for a class method. More...
 
template<class TInstance , class TFunction >
 WorkerThread (ThreadSettings &settings, TInstance &instance, TFunction fn, int idleTime)
 Constructs an WorkerThread instance. More...
 
template<class TInstance , class TFunction >
 WorkerThread (ThreadSettings &settings, const TInstance &instance, TFunction fn, int idleTime)
 Constructs an WorkerThread instance. More...
 
template<class TInstance , class TFunction >
 WorkerThread (ThreadSettings &settings, TInstance *pInstance, TFunction fn, int idleTime)
 Constructs an WorkerThread instance. More...
 
template<class TInstance , class TFunction >
 WorkerThread (ThreadSettings &settings, const TInstance *pInstance, TFunction fn, int idleTime)
 Constructs an WorkerThread instance. More...
 
 WorkerThread (WorkDelegate &&loopDelegate, int idleTime, const char *threadName)
 Constructs an WorkerThread instance. More...
 
 WorkerThread (ThreadSettings &settings, WorkDelegate &&loopDelegate, int idleTime)
 Constructs an WorkerThread instance. More...
 
 ~WorkerThread (void)=default
 Deallocates the memory used for this instance but does not quit the thread. More...
 
bool IsRunning (void) const
 Checks if the thread is in running state. More...
 
void Start (void)
 Starts the execution of the thread. More...
 
void Stop (void)
 Stops the execution of the thread syncronously. More...
 

Detailed Description

Worker threads repeat the execution of the threaded code until Stop is called.

Member Typedef Documentation

◆ WorkDelegate

The delegate of threads loop body.

Constructor & Destructor Documentation

◆ WorkerThread() [1/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( TInstance &  instance,
TFunction  fn,
int  idleTime,
const char *  threadName 
)
inline

Constructs an WorkerThread instance for a class method.

Parameters
instanceInstance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
threadNameThe name of the thread.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [2/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( const TInstance &  instance,
TFunction  fn,
int  idleTime,
const char *  threadName 
)
inline

Constructs an WorkerThread instance for a class method.

Parameters
instanceInstance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
threadNameThe name of the thread.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [3/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( TInstance *  pInstance,
TFunction  fn,
int  idleTime,
const char *  threadName 
)
inline

Constructs an WorkerThread instance for a class method.

Parameters
pInstancePointer to instance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
threadNameThe name of the thread.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [4/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( const TInstance *  pInstance,
TFunction  fn,
int  idleTime,
const char *  threadName 
)
inline

Constructs an WorkerThread instance for a class method.

Parameters
instancePointer to instance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
threadNameThe name of the thread.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [5/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( ThreadSettings settings,
TInstance &  instance,
TFunction  fn,
int  idleTime 
)
inline

Constructs an WorkerThread instance.

Parameters
settingsReference to custom thread parameters.
instanceInstance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [6/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( ThreadSettings settings,
const TInstance &  instance,
TFunction  fn,
int  idleTime 
)
inline

Constructs an WorkerThread instance.

Parameters
settingsReference to custom thread parameters.
instanceInstance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [7/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( ThreadSettings settings,
TInstance *  pInstance,
TFunction  fn,
int  idleTime 
)
inline

Constructs an WorkerThread instance.

Parameters
settingsReference to custom thread parameters.
pInstancePointer to instance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [8/10]

template<class TInstance , class TFunction >
Arp::System::Commons::Threading::WorkerThread::WorkerThread ( ThreadSettings settings,
const TInstance *  pInstance,
TFunction  fn,
int  idleTime 
)
inline

Constructs an WorkerThread instance.

Parameters
settingsReference to custom thread parameters.
pInstancePointer to instance of object whichs method should be executed in separate thread.
fnPointer to method that should be executed in each thread loop.
idleTimeArgThe idle time in ms.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [9/10]

Arp::System::Commons::Threading::WorkerThread::WorkerThread ( WorkDelegate &&  loopDelegate,
int  idleTime,
const char *  threadName 
)
inlineexplicit

Constructs an WorkerThread instance.

Parameters
loopDelegateLoop body delegate to be executed in each thread loop.
idleTimeArgThe idle time in ms.
threadNameThe name of the thread.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ WorkerThread() [10/10]

Arp::System::Commons::Threading::WorkerThread::WorkerThread ( ThreadSettings settings,
WorkDelegate &&  loopDelegate,
int  idleTime 
)
inline

Constructs an WorkerThread instance.

Parameters
settingsReference to custom thread parameters.
loopDelegateLoop body delegate to be executed in each thread loop.
idleTimeArgThe idle time in ms.
Exceptions
Arp::System::Commons::InvalidOperationExceptionif the thread could not be created.

◆ ~WorkerThread()

Arp::System::Commons::Threading::WorkerThread::~WorkerThread ( void  )
default

Deallocates the memory used for this instance but does not quit the thread.

Member Function Documentation

◆ IsRunning()

bool Arp::System::Commons::Threading::WorkerThread::IsRunning ( void  ) const
inline

Checks if the thread is in running state.

Determines if this thread is in running state.

Returns
True if thread is running, otherwise false is returned.

◆ Start()

void Arp::System::Commons::Threading::WorkerThread::Start ( void  )

Starts the execution of the thread.

◆ Stop()

void Arp::System::Commons::Threading::WorkerThread::Stop ( void  )

Stops the execution of the thread syncronously.


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