diff options
author | Jacques Lucke <jacques@blender.org> | 2021-06-16 17:13:53 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-06-16 17:14:02 +0300 |
commit | 45d59e0df5fe749d428ebf662b61844561df64c4 (patch) | |
tree | a70616dc409c67006956ac149bd43efa22c61bc4 /source/blender/modifiers/intern | |
parent | 0cebe554d13bf1ea4c81fd4addee30dd4ea4d2f1 (diff) |
BLI: add threading namespace
This namespace groups threading related functions/classes. This avoids
adding more threading related stuff to the blender namespace. Also it
makes naming a bit easier, e.g. the c++ version of BLI_task_isolate could
become blender::threading::isolate_task or something similar.
Differential Revision: https://developer.blender.org/D11624
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes_evaluator.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc index bcd10cdbf33..3de7497ae3f 100644 --- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc +++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc @@ -352,7 +352,7 @@ class GeometryNodesEvaluator { * on cache line boundaries. Note, just because a value is allocated in one specific thread, * does not mean that it will only be used by that thread. */ - EnumerableThreadSpecific<LinearAllocator<>> local_allocators_; + threading::EnumerableThreadSpecific<LinearAllocator<>> local_allocators_; /** * Every node that is reachable from the output gets its own state. Once all states have been @@ -426,12 +426,13 @@ class GeometryNodesEvaluator { /* Initialize the more complex parts of the node states in parallel. At this point no new * node states are added anymore, so it is safe to lookup states from `node_states_` from * multiple threads. */ - parallel_for(IndexRange(node_states_.size()), 50, [&, this](const IndexRange range) { - LinearAllocator<> &allocator = this->local_allocators_.local(); - for (const NodeWithState &item : node_states_.as_span().slice(range)) { - this->initialize_node_state(item.node, *item.state, allocator); - } - }); + threading::parallel_for( + IndexRange(node_states_.size()), 50, [&, this](const IndexRange range) { + LinearAllocator<> &allocator = this->local_allocators_.local(); + for (const NodeWithState &item : node_states_.as_span().slice(range)) { + this->initialize_node_state(item.node, *item.state, allocator); + } + }); } void initialize_node_state(const DNode node, NodeState &node_state, LinearAllocator<> &allocator) @@ -507,11 +508,12 @@ class GeometryNodesEvaluator { void destruct_node_states() { - parallel_for(IndexRange(node_states_.size()), 50, [&, this](const IndexRange range) { - for (const NodeWithState &item : node_states_.as_span().slice(range)) { - this->destruct_node_state(item.node, *item.state); - } - }); + threading::parallel_for( + IndexRange(node_states_.size()), 50, [&, this](const IndexRange range) { + for (const NodeWithState &item : node_states_.as_span().slice(range)) { + this->destruct_node_state(item.node, *item.state); + } + }); } void destruct_node_state(const DNode node, NodeState &node_state) |