PLCnext API Documentation 25.0.2.69
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

using WorkDelegate = delegate< void(void)>
 The delegate of threads loop body.
 

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.
 
bool IsRunning (void) const
 Checks if the thread is in running state. More...
 
void Start (void)
 Starts the execution of the thread.
 
void Stop (void)
 Stops the execution of the thread syncronously.
 

Detailed Description

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

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  idleTimeArg 
)
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  idleTimeArg 
)
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  idleTimeArg 
)
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  idleTimeArg 
)
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 &&  workDelegate,
int  idleTime,
const char *  threadName 
)

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 &&  workDelegate,
int  idleTimeArg 
)

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.

Member Function Documentation

◆ IsRunning()

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

Checks if the thread is in running state.

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

Determines if this thread is in running state.


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