Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-06-16 17:29:21 +0300
committerJacques Lucke <jacques@blender.org>2021-06-16 17:29:21 +0300
commitb37093de7b42cf331a4ae5830737d9972d7bb426 (patch)
tree73180f2ab3cb83719f96013afb40209ea183bf55 /source/blender/blenlib
parent45d59e0df5fe749d428ebf662b61844561df64c4 (diff)
BLI: add C++ wrapper for task isolation
This makes it easier to use task isolation in c++ code. Previously, one either had to check `WITH_TBB` (possibly indirectly through `WITH_OPENVDB`) or one had to use the C function which is less convenient.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_task.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh
index cdf7759ef41..5f5a17f6b58 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/task_arena.h>
# ifdef WIN32
/* We cannot keep this defined, since other parts of the code deal with this on their own, leading
* to multiple define warnings unless we un-define this, however we can only undefine this if we
@@ -75,4 +76,14 @@ void parallel_for(IndexRange range, int64_t grain_size, const Function &function
#endif
}
+/** See #BLI_task_isolate for a description of what isolating a task means. */
+template<typename Function> void isolate_task(const Function &function)
+{
+#ifdef WITH_TBB
+ tbb::this_task_arena::isolate(function);
+#else
+ function();
+#endif
+}
+
} // namespace blender::threading