Skip to content

Commit

Permalink
Merge pull request #13153 from bangerth/parallel-2
Browse files Browse the repository at this point in the history
Simplify more code in parallel.h via lambda functions.
  • Loading branch information
kronbichler committed Dec 30, 2021
2 parents ddcdae1 + 80a5896 commit 0ffd836
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions include/deal.II/base/parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -743,33 +743,6 @@ namespace internal

namespace parallel
{
#ifdef DEAL_II_WITH_TBB

namespace internal
{
/**
* This is the function actually called by TBB for the ParallelForInteger
* class.
*/
struct ParallelForWrapper
{
ParallelForWrapper(const parallel::ParallelForInteger &worker)
: worker_(worker)
{}

void
operator()(const tbb::blocked_range<std::size_t> &range) const
{
worker_.apply_to_subrange(range.begin(), range.end());
}

const parallel::ParallelForInteger &worker_;
};
} // namespace internal

#endif


inline void
ParallelForInteger::apply_parallel(
const std::size_t begin,
Expand All @@ -783,8 +756,13 @@ namespace parallel

apply_to_subrange(begin, end);
#else
internal::ParallelForWrapper worker(*this);
internal::parallel_for(begin, end, worker, minimum_parallel_grain_size);
internal::parallel_for(
begin,
end,
[this](const tbb::blocked_range<std::size_t> &range) {
apply_to_subrange(range.begin(), range.end());
},
minimum_parallel_grain_size);
#endif
}

Expand Down

0 comments on commit 0ffd836

Please sign in to comment.