Helios++
Helios software for LiDAR simulations
SharedTaskSequencer Class Reference

Class providing core implementation of a shared task sequencer. It is a sequencer which launches shared sub-tasks belonging to the same shared task. More...

#include <SharedTaskSequencer.h>

Inheritance diagram for SharedTaskSequencer:
Collaboration diagram for SharedTaskSequencer:

Public Member Functions

 SharedTaskSequencer (size_t const maxThreads)
 Default constructor for shared task sequencer. More...
 
virtual void start (std::shared_ptr< SharedSubTask > subTask)
 Start given shared sub-task. More...
 
virtual void startThread (std::shared_ptr< SharedSubTask > subTask)
 Assist the start method to start a shared sub-task by wrapping it into a SmartSharedFunctorContainer. More...
 
void onSharedSubTaskCompletion (size_t const key) override
 Handle completion of each shared sub-task. More...
 
virtual void joinAll ()
 Wait until all pending sub-tasks have been finished.
 
- Public Member Functions inherited from SharedSubTaskCompletionHandler
 SharedSubTaskCompletionHandler ()=default
 Default constructor for the shared task completion handler.
 
virtual void onSharedSubTaskCompletion (std::size_t const key)=0
 Pure virtual method that must be overridden by any concrete class to provide handling mechanism for completed shared sub-tasks. More...
 

Protected Attributes

size_t maxThreads = 0
 Maximum number of supported concurrent threads. More...
 
size_t availableThreads = 0
 How many threads there are available to compute a task.
 
size_t nextSharedSubTaskKey = 0
 Key of next shared sub-task to be inserted.
 
unordered_map< size_t, std::shared_ptr< SharedSubTask > > subTasks
 The collection of running shared sub-tasks. More...
 
boost::mutex mtx
 Mutex to handle concurrent start of sub-tasks.
 
boost::condition_variable condvar
 Condition variable to handle concurrent start of sub-tasks.
 

Detailed Description

Class providing core implementation of a shared task sequencer. It is a sequencer which launches shared sub-tasks belonging to the same shared task.

Author
Alberto M. Esmoris Pena
Version
1.0
See also
SharedSubTask
SharedSubTaskCompletionHandler

Constructor & Destructor Documentation

◆ SharedTaskSequencer()

SharedTaskSequencer::SharedTaskSequencer ( size_t const  maxThreads)
inlineexplicit

Default constructor for shared task sequencer.

See also
SharedTaskSequencer::maxThreads

Member Function Documentation

◆ onSharedSubTaskCompletion()

void SharedTaskSequencer::onSharedSubTaskCompletion ( size_t const  key)
override

Handle completion of each shared sub-task.

See also
SharedSubTaskCompletionHandler::onSharedSubTaskCompletion

◆ start()

void SharedTaskSequencer::start ( std::shared_ptr< SharedSubTask subTask)
virtual

Start given shared sub-task.

Parameters
subTaskShared sub-task to be started
See also
SharedSubTask
SharedTaskSequencer::startThread

◆ startThread()

void SharedTaskSequencer::startThread ( std::shared_ptr< SharedSubTask subTask)
virtual

Assist the start method to start a shared sub-task by wrapping it into a SmartSharedFunctorContainer.

Parameters
subTaskThe sub-task to be started
See also
SharedTaskSequencer::start
SharedSubTask
SmartSharedFunctorContainer

Member Data Documentation

◆ maxThreads

size_t SharedTaskSequencer::maxThreads = 0
protected

Maximum number of supported concurrent threads.

If it is 0, it means that there is no limit to concurrent threads.

◆ subTasks

unordered_map<size_t, std::shared_ptr<SharedSubTask> > SharedTaskSequencer::subTasks
protected

The collection of running shared sub-tasks.

Only queued and running shared sub-tasks are included. Those which are fully finished or were not started yet will not be here.


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