Helios++
Helios software for LiDAR simulations
|
Class which handles tasks dropping. It is, executing and then removing each task when dropping. More...
#include <TaskDropper.h>
Public Member Functions | |
TaskDropper (size_t const maxTasks=32) | |
Default constructor for TaskDropper. More... | |
virtual bool | add (shared_ptr< TaskType > task) |
Add a task to the TaskDropper. More... | |
virtual bool | add (shared_ptr< TaskType > task, TaskArgs ... args) |
Like TaskDropper::add but for tasks with arguments. More... | |
virtual bool | add (ThreadPoolType &pool, shared_ptr< TaskType > task) |
Like TaskDropper::add but running the drop method in parallel through a callback from given thread pool. More... | |
virtual char | tryAdd (ThreadPoolType &pool, shared_ptr< TaskType > task) |
Like TaskDropper::add(ThreadPoolType &, shared_ptr<TaskType>) but supporting non-blocking calls. More... | |
virtual void | drop () |
Drop all tasks, one after another. More... | |
virtual void | drop (TaskArgs ... args) |
Drop all tasks with arguments, one after another. More... | |
virtual void | drop (ThreadPoolType &pool) |
A callback for TaskDropper::drop but using a thread pool to be executed in parallel. More... | |
virtual bool | tryDrop (ThreadPoolType &pool) |
Like drop(ThreadPoolType &) but supporting non blocking calls. More... | |
TaskDropper | emptyClone () const |
Do an empty clone of this task dropper. It is, an exact clone but with an empty tasks vector. More... | |
virtual void | operator() () |
Void functor operator calling drop method to be compatible with thread pools. More... | |
virtual void | operator() (TaskArgs ... args) |
Functor operator with arguments calling drop method with arguments which can be used by thread pools. More... | |
virtual size_t | getMaxTasks () const |
Get current maximum tasks limit. More... | |
virtual void | setMaxTasks (size_t const maxTasks) |
Set new maximum tasks limit. More... | |
virtual shared_ptr< TaskType > | popTask () |
Pop a task from vector of tasks. More... | |
Protected Member Functions | |
virtual void | doTask (TaskType &task) |
Execute a task with no arguments. More... | |
virtual void | doTask (TaskType &task, TaskArgs ... args) |
Execute a task with corresponding arguments. More... | |
Protected Attributes | |
std::vector< shared_ptr< TaskType > > | tasks |
Tasks to be dropped as a whole. More... | |
size_t | maxTasks |
Specify the maximum number of tasks before forcing a drop. More... | |
Class which handles tasks dropping. It is, executing and then removing each task when dropping.
TaskType | Type of task handled by the task dropper |
TaskArgs | Arguments for the functor of the task handled by the task dropper |
|
inline |
Default constructor for TaskDropper.
maxTasks | Value to initialize maximum tasks limit |
|
inlinevirtual |
Add a task to the TaskDropper.
task | Task to be added |
|
inlinevirtual |
Like TaskDropper::add but for tasks with arguments.
args | Arguments as common input for each task. They will be used just in case maxTasks limit has been reached |
|
inlinevirtual |
Like TaskDropper::add but running the drop method in parallel through a callback from given thread pool.
pool | Thread pool to be used to do the the drop method callback in parallel |
|
inlineprotectedvirtual |
Execute a task with no arguments.
For implementations handling tasks that mandatory require arguments it is recommended to override this method to throw an exception
task | Task to be executed |
|
inlineprotectedvirtual |
Execute a task with corresponding arguments.
task | Task to be executed |
args | Arguments for the task to be executed |
|
inlinevirtual |
Drop all tasks, one after another.
Dropped tasks will be executed and then released from tasks vector. Notwithstanding, at least for this default implementation, tasks will not be removed from tasks vector until all have been executed
|
inlinevirtual |
Drop all tasks with arguments, one after another.
This method works like TaskDropper::drop but for tasks with arguments
args | Arguments for the task to be executed |
|
inlinevirtual |
A callback for TaskDropper::drop but using a thread pool to be executed in parallel.
The callback TaskDropper::drop will be called through functor operator, with or without arguments depending on the thread pool implementation
pool | Thread pool to be used for parallel execution |
|
inline |
Do an empty clone of this task dropper. It is, an exact clone but with an empty tasks vector.
|
inlinevirtual |
|
inlinevirtual |
Void functor operator calling drop method to be compatible with thread pools.
|
inlinevirtual |
Functor operator with arguments calling drop method with arguments which can be used by thread pools.
args | Arguments for tasks to be executed (the same arguments for each task) |
|
inlinevirtual |
Pop a task from vector of tasks.
|
inlinevirtual |
Set new maximum tasks limit.
maxTasks | New maximum tasks limit |
|
inlinevirtual |
Like TaskDropper::add(ThreadPoolType &, shared_ptr<TaskType>) but supporting non-blocking calls.
|
inlinevirtual |
Like drop(ThreadPoolType &) but supporting non blocking calls.
|
protected |
Specify the maximum number of tasks before forcing a drop.
If it is \(m=0\), then forcing a drop will never happen. If it is \(m>0\), then forcing a drop will happen as soon as \(\vert\vec{T}\vert = m\) is satisfied
|
protected |
Tasks to be dropped as a whole.
Task vector is denoted in the documentation as \(\vec{T}\)