diff options
author | Jacques Lucke <jacques@blender.org> | 2022-02-09 15:08:04 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-02-09 15:08:04 +0300 |
commit | 7c10e364b2358f08fa49ce35fc98d4de1431e615 (patch) | |
tree | 0e5cf3a6845ad8229dc3ce9988e16b0caa29b460 /source/blender/blenlib/BLI_task.hh | |
parent | 3f061ef050ccb671f9c4c9b65a17f0d097e24344 (diff) |
BLI: wrap parallel_invoke from tbb
Diffstat (limited to 'source/blender/blenlib/BLI_task.hh')
-rw-r--r-- | source/blender/blenlib/BLI_task.hh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh index 84d5cd39bb4..8f75aa19cfe 100644 --- a/source/blender/blenlib/BLI_task.hh +++ b/source/blender/blenlib/BLI_task.hh @@ -31,6 +31,7 @@ # include <tbb/blocked_range.h> # include <tbb/parallel_for.h> # include <tbb/parallel_for_each.h> +# include <tbb/parallel_invoke.h> # include <tbb/parallel_reduce.h> # include <tbb/task_arena.h> # ifdef WIN32 @@ -103,6 +104,19 @@ Value parallel_reduce(IndexRange range, #endif } +/** + * Execute all of the provided functions. The functions might be executed in parallel or in serial + * or some combination of both. + */ +template<typename... Functions> void parallel_invoke(Functions &&...functions) +{ +#ifdef WITH_TBB + tbb::parallel_invoke(std::forward<Functions>(functions)...); +#else + (functions(), ...); +#endif +} + /** See #BLI_task_isolate for a description of what isolating a task means. */ template<typename Function> void isolate_task(const Function &function) { |