7 #ifndef PXR_BASE_WORK_TBB_DISPATCHER_IMPL_H
8 #define PXR_BASE_WORK_TBB_DISPATCHER_IMPL_H
15 #include <tbb/blocked_range.h>
16 #include <tbb/concurrent_vector.h>
17 #if TBB_INTERFACE_VERSION_MAJOR >= 12
18 #include <tbb/task_group.h>
24 #include <type_traits>
39 WorkImpl_Dispatcher &
operator=(WorkImpl_Dispatcher
const &) =
delete;
41 template <
class Callable>
42 inline void Run(Callable &&
c) {
43 #if TBB_INTERFACE_VERSION_MAJOR >= 12
44 _taskGroup.run(std::forward<Callable>(
c));
49 std::forward<Callable>(
c)));
71 #if TBB_INTERFACE_VERSION_MAJOR < 12
75 : _fn(std::move(fn)) {}
92 #if TBB_INTERFACE_VERSION_MAJOR >= 12
94 class _TaskGroup :
public tbb::task_group {
96 _TaskGroup(tbb::task_group_context& ctx) : tbb::task_group(ctx) {}
97 inline tbb::detail::d1::wait_context& _GetInternalWaitContext();
100 _TaskGroup _taskGroup;
113 #endif // PXR_BASE_WORK_TBB_DISPATCHER_IMPL_H
WORK_API ~WorkImpl_Dispatcher() noexcept
Wait() for any pending tasks to complete, then destroy the dispatcher.
#define PXR_NAMESPACE_OPEN_SCOPE
tbb::task_group_context _context
_InvokerTaskWrapper(Fn &&fn)
WorkImpl_Dispatcher & operator=(WorkImpl_Dispatcher const &)=delete
WORK_API WorkImpl_Dispatcher()
Construct a new dispatcher.
virtual tbb::task * execute()
WORK_API void Wait()
Block until the work started by Run() completes.
#define PXR_NAMESPACE_CLOSE_SCOPE
_InvokerTaskWrapper(Fn const &fn)
WORK_API void Reset()
Reinitialize context for WorkImpl_Dispatcher if it has one.
tbb::empty_task * _rootTask