Public Member Functions | Private Attributes | List of all members
xsens::TaskCompletionWaiter Class Reference

A class that allows multiple-dependency waiting. More...

#include <xsens_threadpool.h>

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

Public Member Functions

void addWaitId (unsigned int id)
 Add the id of a task to wiat for to the list. More...
 
virtual bool exec ()
 task function, checks if there are tasks left that we should be waiting for More...
 
virtual unsigned int needToWaitFor ()
 If there are wait tasks left, this function will return the id of the first in the list. More...
 
 TaskCompletionWaiter (const std::list< unsigned int > &waitlist, ThreadPool *pool=ThreadPool::instance())
 Constructor, sets up a waiter that waits for all items in the list to be completed. More...
 
 TaskCompletionWaiter (ThreadPool *pool=ThreadPool::instance())
 Constructor, sets up an empty waiter. More...
 
virtual ~TaskCompletionWaiter ()
 Destructor. More...
 
- Public Member Functions inherited from xsens::ThreadPoolTask
bool isCanceling () const
 Returns true if the task has been told to cancel itself. More...
 
unsigned int taskId () const
 Returns the task ID of the task or 0 if it doesn't have a proper ID (yet) More...
 
 ThreadPoolTask ()
 
virtual ~ThreadPoolTask ()
 

Private Attributes

ThreadPoolm_pool
 
std::list< unsigned int > m_waitList
 

Detailed Description

A class that allows multiple-dependency waiting.

A normal task in the ThreadPool can only wait for one task ID. This class allows waiting for multiple IDs. The IDs to wait for can be supplied upon creation or added later, but they should NOT be added once the object has been scheduled. The TaskCompletionWaiter must be scheduled in the ThreadPool that contains the task IDs to wait for so it can do its job.

Note
If you want a thread outside the ThreadPool to wait for multiple tasks to complete, create a TaskCompletionWaiter, schedule it and wait for the TaskCompletionWaiter to complete through the ThreadPool::waitForCompletion function.

Definition at line 146 of file xsens_threadpool.h.

Constructor & Destructor Documentation

◆ TaskCompletionWaiter() [1/2]

xsens::TaskCompletionWaiter::TaskCompletionWaiter ( ThreadPool pool = ThreadPool::instance())

Constructor, sets up an empty waiter.

Definition at line 807 of file xsens_threadpool.cpp.

◆ TaskCompletionWaiter() [2/2]

xsens::TaskCompletionWaiter::TaskCompletionWaiter ( const std::list< unsigned int > &  waitlist,
ThreadPool pool = ThreadPool::instance() 
)

Constructor, sets up a waiter that waits for all items in the list to be completed.

Definition at line 813 of file xsens_threadpool.cpp.

◆ ~TaskCompletionWaiter()

xsens::TaskCompletionWaiter::~TaskCompletionWaiter ( )
virtual

Destructor.

Definition at line 820 of file xsens_threadpool.cpp.

Member Function Documentation

◆ addWaitId()

void xsens::TaskCompletionWaiter::addWaitId ( unsigned int  id)

Add the id of a task to wiat for to the list.

Parameters
idThe ID to add
Note
This function should NOT be called once the task has been scheduled!

Definition at line 854 of file xsens_threadpool.cpp.

◆ exec()

bool xsens::TaskCompletionWaiter::exec ( )
virtual

task function, checks if there are tasks left that we should be waiting for

The function returns false if at least one of the wait tasks still exists

Returns
True if successfully executed

Implements xsens::ThreadPoolTask.

Definition at line 827 of file xsens_threadpool.cpp.

◆ needToWaitFor()

unsigned int xsens::TaskCompletionWaiter::needToWaitFor ( )
virtual

If there are wait tasks left, this function will return the id of the first in the list.

Returns
The id of the first task in the list

Reimplemented from xsens::ThreadPoolTask.

Definition at line 843 of file xsens_threadpool.cpp.

Member Data Documentation

◆ m_pool

ThreadPool* xsens::TaskCompletionWaiter::m_pool
private

Definition at line 158 of file xsens_threadpool.h.

◆ m_waitList

std::list<unsigned int> xsens::TaskCompletionWaiter::m_waitList
private

Definition at line 159 of file xsens_threadpool.h.


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


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