8 #include "Arp/System/Commons/Threading/Thread.hpp" 10 namespace Arp {
namespace System {
namespace Commons {
namespace Threading
28 template<
class TInstance,
class TFunction>
29 WorkerThread(TInstance& instance, TFunction fn,
int idleTime,
const char* threadName);
37 template<
class TInstance,
class TFunction>
38 WorkerThread(
const TInstance& instance, TFunction fn,
int idleTime,
const char* threadName);
46 template<
class TInstance,
class TFunction>
47 WorkerThread(TInstance* pInstance, TFunction fn,
int idleTime,
const char* threadName);
55 template<
class TInstance,
class TFunction>
56 WorkerThread(
const TInstance* pInstance, TFunction fn,
int idleTime,
const char* threadName);
64 template<
class TInstance,
class TFunction>
73 template<
class TInstance,
class TFunction>
82 template<
class TInstance,
class TFunction>
91 template<
class TInstance,
class TFunction>
99 explicit WorkerThread(WorkDelegate&& loopDelegate,
int idleTime,
const char* threadName);
125 static void RunInternal(
void* pParam);
130 std::atomic<bool> stopWorking{
false};
131 std::atomic<bool> isStarted{
false};
138 template<
class TInstance,
class TFunction>
144 template<
class TInstance,
class TFunction>
150 template<
class TInstance,
class TFunction>
156 this->thread.
SetName(threadName);
159 template<
class TInstance,
class TFunction>
165 this->thread.
SetName(threadName);
173 this->thread.
SetName(threadName);
176 template<
class TInstance,
class TFunction>
182 template<
class TInstance,
class TFunction>
188 template<
class TInstance,
class TFunction>
191 , idleTime(idleTimeArg)
200 template<
class TInstance,
class TFunction>
203 , idleTime(idleTimeArg)
214 , idleTime(idleTimeArg)
String Name
Name for the thread.
Definition: ThreadSettings.hpp:28
delegate< R(A...)> make_delegate(R(*const function_ptr)(A...)) noexcept
Creates a delegate from a static function.
Definition: delegate.hxx:215
size_t CpuAffinity
CPU affinity mask determine which CPU is allowed to run the thread.
Definition: ThreadSettings.hpp:36
void Start(void)
Starts the execution of the thread.
Worker threads repeat the execution of the threaded code until Stop is called.
Definition: WorkerThread.hpp:14
~WorkerThread(void)=default
Deallocates the memory used for this instance but does not quit the thread.
void SetStackSize(size_t value)
Sets a new stack size for the thread.
The Thread-class provides methods to execute functions and methods in a separate thread.
Definition: Thread.hpp:91
void Stop(void)
Stops the execution of the thread syncronously.
void SetPriority(size_t value)
Assigns a new priority to the thread.
bool IsRunning(void) const
Determines if this thread is in running state.
Definition: Thread.hpp:605
bool IsRunning(void) const
Checks if the thread is in running state.
Definition: WorkerThread.hpp:224
void SetName(const String &value)
Sets a new name to the thread.
size_t Priority
Priority of thread.
Definition: ThreadSettings.hpp:31
delegate< void(void)> WorkDelegate
The delegate of threads loop body.
Definition: WorkerThread.hpp:18
Container class for adaptable thread settings.
Definition: ThreadSettings.hpp:12
Root namespace for the PLCnext API
WorkerThread(TInstance &instance, TFunction fn, int idleTime, const char *threadName)
Constructs an WorkerThread instance for a class method.
Definition: WorkerThread.hpp:139
size_t StackSize
Bytes-size of requested stack for new thread.
Definition: ThreadSettings.hpp:39
System components used by the System, Device, Plc or Io domains.
void SetCpuAffinity(size_t mask)
Pins the thread to a specific CPUs inside a multiprocessor system.