Loading...
Searching...
No Matches
WorkTaskGraph Class Reference

Instances of this class are used to spawn and wait on a directed graph of tasks, where tasks preserve a pointer to their parent task/successor and a ref count to dynamically track pending children. More...

#include <taskGraph.h>

Classes

class  BaseTask
 Base class for a parallel task that emulates tbb::task (deprecated in the oneTBB version upgrade.) This task abstracts a block of concurrent work
by exploiting knowledge of TBB's task-based work stealing scheduler architecture to provide memory and runtime optimizations. More...
 

Public Types

using TaskList = std::vector< BaseTask * >
 Container for allocated tasks to be spawned.
 
using TaskLists = tbb::enumerable_thread_specific< TaskList >
 Thread-local storage for allocated tasks to be spawned.
 

Public Member Functions

 WorkTaskGraph (WorkTaskGraph const &)=delete
 
WorkTaskGraphoperator= (WorkTaskGraph const &)=delete
 
template<typename F , typename ... Args>
F * AllocateTask (Args &&... args)
 Allocate and construct a new top-level task to run with RunTask() or RunLists().
 
template<typename F >
void RunTask (F *task)
 Submit a concurrent task for execution.
 
WORK_API void RunLists (const TaskLists &taskLists)
 Submit concurrent tasks accumulated in thread-local lists for execution.
 
void Wait ()
 Wait on all the running tasks to complete.
 

Detailed Description

Instances of this class are used to spawn and wait on a directed graph of tasks, where tasks preserve a pointer to their parent task/successor and a ref count to dynamically track pending children.

It supports adding new tasks during the execution of running tasks, continuation passing, recycling of task resources, and scheduler bypass.

This organization of tasks is suited for problems that exhibit hierarchical structured parallelism: tasks that discover additional work during their execution. If these optimizations are not required, consider a higher-level abstraction, e.g. WorkParallelForEach or direct submission of work via WorkDispatcher.

Definition at line 36 of file taskGraph.h.

Member Typedef Documentation

◆ TaskList

using TaskList = std::vector<BaseTask *>

Container for allocated tasks to be spawned.

Definition at line 57 of file taskGraph.h.

◆ TaskLists

using TaskLists = tbb::enumerable_thread_specific<TaskList>

Thread-local storage for allocated tasks to be spawned.

Definition at line 60 of file taskGraph.h.

Member Function Documentation

◆ AllocateTask()

F * AllocateTask ( Args &&...  args)
inline

Allocate and construct a new top-level task to run with RunTask() or RunLists().

The caller owns the returned task until it is passed to RunTask() or RunLists().

Definition at line 68 of file taskGraph.h.

◆ RunLists()

WORK_API void RunLists ( const TaskLists taskLists)

Submit concurrent tasks accumulated in thread-local lists for execution.

Transfers ownership of all the tasks in the taskLists to this task graph instance.

◆ RunTask()

void RunTask ( F *  task)
inline

Submit a concurrent task for execution.

Transfers ownership of task to this task graph instance.

Definition at line 76 of file taskGraph.h.

◆ Wait()

void Wait ( )
inline

Wait on all the running tasks to complete.

Definition at line 88 of file taskGraph.h.


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