]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify more code in parallel.h via lambda functions. 13153/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 29 Dec 2021 19:21:14 +0000 (12:21 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 29 Dec 2021 19:28:27 +0000 (12:28 -0700)
include/deal.II/base/parallel.h

index bef3174dd1ee291591c4539ddbaee2e75980bef9..b86fda95d1a0e8ae7a9fd6697bf6df6545f41e66 100644 (file)
@@ -808,33 +808,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,
@@ -848,8 +821,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
   }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.