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/blenkernel | |
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/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_validate.cc | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/spline_base.cc | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/spline_bezier.cc | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 0b0aeb50d37..574ab785445 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -87,7 +87,7 @@ static void reserve_hash_maps(const Mesh *mesh, MutableSpan<EdgeMap> edge_maps) { const int totedge_guess = std::max(keep_existing_edges ? mesh->totedge : 0, mesh->totpoly * 2); - parallel_for_each( + threading::parallel_for_each( edge_maps, [&](EdgeMap &edge_map) { edge_map.reserve(totedge_guess / edge_maps.size()); }); } @@ -96,7 +96,7 @@ static void add_existing_edges_to_hash_maps(Mesh *mesh, uint32_t parallel_mask) { /* Assume existing edges are valid. */ - parallel_for_each(edge_maps, [&](EdgeMap &edge_map) { + threading::parallel_for_each(edge_maps, [&](EdgeMap &edge_map) { const int task_index = &edge_map - &edge_maps[0]; for (const MEdge &edge : Span(mesh->medge, mesh->totedge)) { OrderedEdge ordered_edge{edge.v1, edge.v2}; @@ -113,7 +113,7 @@ static void add_polygon_edges_to_hash_maps(Mesh *mesh, uint32_t parallel_mask) { const Span<MLoop> loops{mesh->mloop, mesh->totloop}; - parallel_for_each(edge_maps, [&](EdgeMap &edge_map) { + threading::parallel_for_each(edge_maps, [&](EdgeMap &edge_map) { const int task_index = &edge_map - &edge_maps[0]; for (const MPoly &poly : Span(mesh->mpoly, mesh->totpoly)) { Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop); @@ -146,7 +146,7 @@ static void serialize_and_initialize_deduplicated_edges(MutableSpan<EdgeMap> edg edge_index_offsets[i + 1] = edge_index_offsets[i] + edge_maps[i].size(); } - parallel_for_each(edge_maps, [&](EdgeMap &edge_map) { + threading::parallel_for_each(edge_maps, [&](EdgeMap &edge_map) { const int task_index = &edge_map - &edge_maps[0]; int new_edge_index = edge_index_offsets[task_index]; @@ -174,7 +174,7 @@ static void update_edge_indices_in_poly_loops(Mesh *mesh, uint32_t parallel_mask) { const MutableSpan<MLoop> loops{mesh->mloop, mesh->totloop}; - parallel_for(IndexRange(mesh->totpoly), 100, [&](IndexRange range) { + threading::parallel_for(IndexRange(mesh->totpoly), 100, [&](IndexRange range) { for (const int poly_index : range) { MPoly &poly = mesh->mpoly[poly_index]; MutableSpan<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop); @@ -215,7 +215,7 @@ static int get_parallel_maps_count(const Mesh *mesh) static void clear_hash_tables(MutableSpan<EdgeMap> edge_maps) { - parallel_for_each(edge_maps, [](EdgeMap &edge_map) { edge_map.clear(); }); + threading::parallel_for_each(edge_maps, [](EdgeMap &edge_map) { edge_map.clear(); }); } } // namespace blender::bke::calc_edges diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc index c9d4f62845f..f58d15c06fe 100644 --- a/source/blender/blenkernel/intern/spline_base.cc +++ b/source/blender/blenkernel/intern/spline_base.cc @@ -378,7 +378,7 @@ void Spline::sample_based_on_index_factors(const GVArray &src, using T = decltype(dummy); const GVArray_Typed<T> src_typed = src.typed<T>(); MutableSpan<T> dst_typed = dst.typed<T>(); - blender::parallel_for(dst_typed.index_range(), 1024, [&](IndexRange range) { + blender::threading::parallel_for(dst_typed.index_range(), 1024, [&](IndexRange range) { for (const int i : range) { const LookupResult interp = this->lookup_data_from_index_factor(index_factors[i]); dst_typed[i] = blender::attribute_math::mix2(interp.factor, diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc index bd68d49df21..88b680850cf 100644 --- a/source/blender/blenkernel/intern/spline_bezier.cc +++ b/source/blender/blenkernel/intern/spline_bezier.cc @@ -417,7 +417,7 @@ static void calculate_mappings_linear_resolution(Span<int> offsets, } const int grain_size = std::max(2048 / resolution, 1); - parallel_for(IndexRange(1, size - 2), grain_size, [&](IndexRange range) { + blender::threading::parallel_for(IndexRange(1, size - 2), grain_size, [&](IndexRange range) { for (const int i_control_point : range) { const int segment_len = offsets[i_control_point + 1] - offsets[i_control_point]; const float segment_len_inv = 1.0f / segment_len; @@ -497,7 +497,7 @@ Span<float3> BezierSpline::evaluated_positions() const Span<int> offsets = this->control_point_offsets(); const int grain_size = std::max(512 / resolution_, 1); - parallel_for(IndexRange(size - 1), grain_size, [&](IndexRange range) { + blender::threading::parallel_for(IndexRange(size - 1), grain_size, [&](IndexRange range) { for (const int i : range) { this->evaluate_segment(i, i + 1, positions.slice(offsets[i], offsets[i + 1] - offsets[i])); } |