Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
xsens::PooledThread Class Reference

A class that contains a thread that runs in a ThreadPool to execute tasks. More...

Inheritance diagram for xsens::PooledThread:
Inheritance graph
[legend]

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...
 
- Public Member Functions inherited from xsens::StandardThread
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...
 
- Protected Member Functions inherited from xsens::StandardThread
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...
 
ThreadPoolm_pool
 The pool that contains this thread. More...
 
std::shared_ptr< PooledTaskm_task
 The task that is currently being executed or NULL if the thread is idle. More...
 
- Protected Attributes inherited from xsens::StandardThread
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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PooledThread()

xsens::PooledThread::PooledThread ( ThreadPool pool)

Constructor.

Definition at line 232 of file xsens_threadpool.cpp.

◆ ~PooledThread()

xsens::PooledThread::~PooledThread ( )

Destructor.

Definition at line 243 of file xsens_threadpool.cpp.

Member Function Documentation

◆ completedCount()

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.

◆ executedCount()

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.

◆ failedCount()

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.

◆ innerFunction()

int32_t xsens::PooledThread::innerFunction ( void  )
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.

◆ isBusy()

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.

◆ isIdle()

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.

Member Data Documentation

◆ m_completed

unsigned int xsens::PooledThread::m_completed
protected

The number of tasks that this thread has completed so far, excluding incomplete tasks.

Definition at line 225 of file xsens_threadpool.cpp.

◆ m_executed

unsigned int xsens::PooledThread::m_executed
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.

◆ m_failed

unsigned int xsens::PooledThread::m_failed
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.

◆ m_pool

ThreadPool* xsens::PooledThread::m_pool
protected

The pool that contains this thread.

Definition at line 222 of file xsens_threadpool.cpp.

◆ m_task

std::shared_ptr<PooledTask> xsens::PooledThread::m_task
protected

The task that is currently being executed or NULL if the thread is idle.

Definition at line 223 of file xsens_threadpool.cpp.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:23