7#ifndef PXR_BASE_WORK_TASK_GRAPH_H
8#define PXR_BASE_WORK_TASK_GRAPH_H
12#include "pxr/base/work/api.h"
14#include "pxr/base/work/impl.h"
15#include "pxr/base/work/taskGraph_defaultImpl.h"
17#include <tbb/enumerable_thread_specific.h>
22PXR_NAMESPACE_OPEN_SCOPE
40#if defined WORK_IMPL_HAS_TASK_GRAPH
41 using _Impl = PXR_WORK_IMPL_NS::WorkImpl_TaskGraph;
43 using _Impl = WorkTaskGraph_DefaultImpl;
60 using TaskLists = tbb::enumerable_thread_specific<TaskList>;
67 template <
typename F,
typename ... Args>
69 return _impl.AllocateTask<F>(std::forward<Args>(args)...);
108 using _Base = WorkTaskGraph::_Impl::BaseTask;
121 _Base::AddChildReference();
127 return _Base::RemoveChildReference();
132 template <
typename F,
typename ... Args>
134 return _Base::AllocateChild<F>(std::forward<Args>(args)...);
148 _Base::_RecycleAsContinuation();
154PXR_NAMESPACE_CLOSE_SCOPE
Base class for a parallel task that emulates tbb::task (deprecated in the oneTBB version upgrade....
void _RecycleAsContinuation()
Recycles this as a continuation task to mitigate the allocation overhead of the continuation task.
F * AllocateChild(Args &&... args)
Construct a new subtask and increment the reference count of the calling task.
virtual BaseTask * execute()=0
Derived classes override this method to implement a parallel unit of work.
void AddChildReference()
Increment the reference count of child tasks that must complete before this task can proceed.
int RemoveChildReference()
Decrement the reference count of child tasks that must complete before this task can proceed.
Instances of this class are used to spawn and wait on a directed graph of tasks, where tasks preserve...
F * AllocateTask(Args &&... args)
Allocate and construct a new top-level task to run with RunTask() or RunLists().
WORK_API void RunLists(const TaskLists &taskLists)
Submit concurrent tasks accumulated in thread-local lists for execution.
tbb::enumerable_thread_specific< TaskList > TaskLists
Thread-local storage for allocated tasks to be spawned.
void RunTask(F *task)
Submit a concurrent task for execution.
void Wait()
Wait on all the running tasks to complete.
std::vector< BaseTask * > TaskList
Container for allocated tasks to be spawned.