A class that contains a thread that runs in a ThreadPool to execute tasks. More...
Public Member Functions | |
unsigned int | completedCount () const |
Return the number of tasks successfully executed by the thread. More... | |
unsigned int | executedCount () const |
Return the number of tasks successfully or partially executed by the thread. More... | |
unsigned int | failedCount () const |
Return the number of tasks that failed to execute properly. More... | |
bool | isBusy () const |
Return whether the thread is currently executing a task (true) or not (false) More... | |
bool | isIdle () const |
Return whether the thread is currently executing a task (false) or not (true) More... | |
PooledThread (ThreadPool *pool) | |
Constructor. More... | |
~PooledThread () | |
Destructor. More... | |
![]() | |
XsThreadId | getThreadId (void) const |
bool | isAlive (void) volatile const noexcept |
bool | isRunning (void) volatile const noexcept |
Returns whether the thread is currently running. More... | |
bool | isTerminating () volatile const noexcept |
Returns whether the thread should (have) terminate(d) More... | |
bool | setPriority (XsThreadPriority pri) |
Sets the priority of the thread. More... | |
virtual void | signalStopThread (void) |
Tells the thread to stop but does not wait for it to end. More... | |
StandardThread () | |
bool | startThread (const char *name=NULL) |
Starts the thread. More... | |
void | stopThread (void) noexcept |
Tells the thread to stop and waits for it to end. More... | |
virtual | ~StandardThread () |
Protected Member Functions | |
int32_t | innerFunction (void) override |
The inner function of the pooled thread. More... | |
![]() | |
virtual void | exitFunction (void) |
Virtual exit function. More... | |
virtual void | initFunction (void) |
Virtual initialization function. More... | |
XsThread | threadHandle () const |
Return the thread handle. More... | |
Protected Attributes | |
unsigned int | m_completed |
The number of tasks that this thread has completed so far, excluding incomplete tasks. More... | |
unsigned int | m_executed |
The number of tasks that this thread has executed s o far, including incomplete tasks. More... | |
unsigned int | m_failed |
The number of tasks that this thread has failed to complete so far due to an exception. More... | |
ThreadPool * | m_pool |
The pool that contains this thread. More... | |
std::shared_ptr< PooledTask > | m_task |
The task that is currently being executed or NULL if the thread is idle. More... | |
![]() | |
pthread_attr_t | m_attr |
Duplicates m_stop functionality for external dependent classes such as Semaphore. More... | |
bool | m_running |
Indicates that the thread is running. More... | |
volatile std::atomic_bool | m_stop |
Indicates that the thread should stop. Derived classes should check isTerminating() instead of directly polling this value when checking if the thread should stop. However, there are some cases (tests, SignallingThread) where direct access from within the class is desired, which is why the vlaue is protected instead of private. More... | |
volatile std::atomic_bool | m_yieldOnZeroSleep |
When true, a sleep value of 0 returned by innerFunction will trigger a thread yield operation. When false, the next cycle is started immediately. More... | |
A class that contains a thread that runs in a ThreadPool to execute tasks.
These threads are created by the ThreadPool.
Definition at line 210 of file xsens_threadpool.cpp.
xsens::PooledThread::PooledThread | ( | ThreadPool * | pool | ) |
Constructor.
Definition at line 232 of file xsens_threadpool.cpp.
xsens::PooledThread::~PooledThread | ( | ) |
Destructor.
Definition at line 243 of file xsens_threadpool.cpp.
unsigned int xsens::PooledThread::completedCount | ( | ) | const |
Return the number of tasks successfully executed by the thread.
Definition at line 338 of file xsens_threadpool.cpp.
unsigned int xsens::PooledThread::executedCount | ( | ) | const |
Return the number of tasks successfully or partially executed by the thread.
Definition at line 331 of file xsens_threadpool.cpp.
unsigned int xsens::PooledThread::failedCount | ( | ) | const |
Return the number of tasks that failed to execute properly.
Definition at line 345 of file xsens_threadpool.cpp.
|
overrideprotectedvirtual |
The inner function of the pooled thread.
The function will do tasks until the ThreadPool no longer supplies any tasks, at which point it will return with a sleep time of 1ms.
Reimplemented from xsens::StandardThread.
Definition at line 254 of file xsens_threadpool.cpp.
bool xsens::PooledThread::isBusy | ( | ) | const |
Return whether the thread is currently executing a task (true) or not (false)
Definition at line 324 of file xsens_threadpool.cpp.
bool xsens::PooledThread::isIdle | ( | ) | const |
Return whether the thread is currently executing a task (false) or not (true)
Definition at line 317 of file xsens_threadpool.cpp.
|
protected |
The number of tasks that this thread has completed so far, excluding incomplete tasks.
Definition at line 225 of file xsens_threadpool.cpp.
|
protected |
The number of tasks that this thread has executed s o far, including incomplete tasks.
Definition at line 224 of file xsens_threadpool.cpp.
|
protected |
The number of tasks that this thread has failed to complete so far due to an exception.
Definition at line 226 of file xsens_threadpool.cpp.
|
protected |
The pool that contains this thread.
Definition at line 222 of file xsens_threadpool.cpp.
|
protected |
The task that is currently being executed or NULL if the thread is idle.
Definition at line 223 of file xsens_threadpool.cpp.