Classes | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
xsens::TaskThread Class Reference

Class for handling small tasks. More...

#include <threading.h>

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

Classes

struct  TaskType
 

Public Types

typedef void(CDECL_XSTaskFunction) (void *)
 A function prototype for a task. More...
 

Public Member Functions

void addTask (TaskFunction func, void *param)
 Adds a task to a queue. More...
 
void clear (void)
 Clears a queue. More...
 
int32_t getLength (void) noexcept
 
 TaskThread ()
 
 ~TaskThread ()
 
- 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

virtual int32_t innerFunction (void)
 The inner function of the task 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...
 

Private Attributes

bool m_inFunc
 
std::deque< TaskTypem_queue
 
Mutex m_safe
 

Additional Inherited Members

- 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

Class for handling small tasks.

Use this class if you have small tasks that need to be performed out of the main thread The thread uses tasks supplied in a TaskType struct.

Definition at line 219 of file threading.h.

Member Typedef Documentation

◆ TaskFunction

typedef void(CDECL_XS* xsens::TaskThread::TaskFunction) (void *)

A function prototype for a task.

Definition at line 222 of file threading.h.

Constructor & Destructor Documentation

◆ TaskThread()

xsens::TaskThread::TaskThread ( )
inline

Definition at line 259 of file threading.h.

◆ ~TaskThread()

xsens::TaskThread::~TaskThread ( )
inline

Definition at line 260 of file threading.h.

Member Function Documentation

◆ addTask()

void xsens::TaskThread::addTask ( TaskFunction  func,
void *  param 
)
inline

Adds a task to a queue.

Parameters
funcThe function to add
paramThe parameters to add

Definition at line 270 of file threading.h.

◆ clear()

void xsens::TaskThread::clear ( void  )
inline

Clears a queue.

Definition at line 285 of file threading.h.

◆ getLength()

int32_t xsens::TaskThread::getLength ( void  )
inlinenoexcept
Returns
The length of a queue

Definition at line 278 of file threading.h.

◆ innerFunction()

virtual int32_t xsens::TaskThread::innerFunction ( void  )
inlineprotectedvirtual

The inner function of the task thread.

The function checks if there is a task in the queue and executes it. Then it returns to the StandardThread main loop to check for termination. If there are no tasks in the queue, the thread will terminate itself.

Returns
Not 0 if successful

Reimplemented from xsens::StandardThread.

Definition at line 241 of file threading.h.

Member Data Documentation

◆ m_inFunc

bool xsens::TaskThread::m_inFunc
private

Definition at line 232 of file threading.h.

◆ m_queue

std::deque<TaskType> xsens::TaskThread::m_queue
private

Definition at line 230 of file threading.h.

◆ m_safe

Mutex xsens::TaskThread::m_safe
private

Definition at line 231 of file threading.h.


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