HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WorkTaskGraph Class Reference

#include <taskGraph.h>

Classes

class  BaseTask
 

Public Types

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

Public Member Functions

 WorkTaskGraph ()=default
 
 ~WorkTaskGraph () noexcept=default
 
 WorkTaskGraph (WorkTaskGraph const &)=delete
 
WorkTaskGraphoperator= (WorkTaskGraph const &)=delete
 
template<typename F , typename... Args>
F * AllocateTask (Args &&...args)
 
template<typename F >
void RunTask (F *task)
 
WORK_API void RunLists (const TaskLists &taskLists)
 
void Wait ()
 Wait on all the running tasks to complete. More...
 

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

using WorkTaskGraph::TaskList = std::vector<BaseTask *>

Container for allocated tasks to be spawned.

Definition at line 57 of file taskGraph.h.

using WorkTaskGraph::TaskLists = tbb::enumerable_thread_specific<TaskList>

Thread-local storage for allocated tasks to be spawned.

Definition at line 60 of file taskGraph.h.

Constructor & Destructor Documentation

WorkTaskGraph::WorkTaskGraph ( )
default
WorkTaskGraph::~WorkTaskGraph ( )
defaultnoexcept
WorkTaskGraph::WorkTaskGraph ( WorkTaskGraph const &  )
delete

Member Function Documentation

template<typename F , typename... Args>
F* WorkTaskGraph::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.

WorkTaskGraph& WorkTaskGraph::operator= ( WorkTaskGraph const &  )
delete
WORK_API void WorkTaskGraph::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.

template<typename F >
void WorkTaskGraph::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.

void WorkTaskGraph::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: