7#ifndef PXR_BASE_WORK_WITH_SCOPED_PARALLELISM_H
8#define PXR_BASE_WORK_WITH_SCOPED_PARALLELISM_H
13#include "pxr/base/work/api.h"
15#include "pxr/base/tf/pyLock.h"
17#include <tbb/task_arena.h>
21PXR_NAMESPACE_OPEN_SCOPE
99WorkWithScopedParallelism(Fn &&fn,
bool dropPythonGIL=
true)
102 TF_PY_ALLOW_THREADS_IN_SCOPE();
103 return tbb::this_task_arena::isolate(std::forward<Fn>(fn));
106 return tbb::this_task_arena::isolate(std::forward<Fn>(fn));
118WorkWithScopedDispatcher(Fn &&fn,
bool dropPythonGIL=
true)
120 return WorkWithScopedParallelism([&fn]() {
122 return std::forward<Fn>(fn)(dispatcher);
127PXR_NAMESPACE_CLOSE_SCOPE
A work dispatcher runs concurrent tasks.