]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use lambdas to make some code simpler. 4207/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Apr 2017 16:46:33 +0000 (10:46 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 8 Apr 2017 22:18:57 +0000 (16:18 -0600)
source/fe/fe_system.cc

index 17b6d44a1e670ea55fbd54f6a205e3abd788d2be..c5ee6e909017946caf97661bc8b141b9b12b73ae 100644 (file)
@@ -1468,27 +1468,27 @@ void FESystem<dim,spacedim>::initialize (const std::vector<const FiniteElement<d
     if (multiplicities[i]>0)
       this->base_to_block_indices.push_back( multiplicities[i] );
 
-  std::vector<Threads::Task<FiniteElement<dim,spacedim>*> > clone_base_elements;
-
-  for (unsigned int i=0; i<fes.size(); i++)
-    if (multiplicities[i]>0)
-      clone_base_elements.push_back (Threads::new_task (&FiniteElement<dim,spacedim>::clone,
-                                                        *fes[i]));
+  {
+    Threads::TaskGroup<> clone_base_elements;
 
-  unsigned int ind=0;
-  for (unsigned int i=0; i<fes.size(); i++)
-    {
+    unsigned int ind=0;
+    for (unsigned int i=0; i<fes.size(); i++)
       if (multiplicities[i]>0)
         {
-          base_elements[ind] =
-            std::make_pair (std::shared_ptr<const FiniteElement<dim,spacedim> >
-                            (clone_base_elements[ind].return_value()),
-                            multiplicities[i]);
+          clone_base_elements += Threads::new_task ([ &,i,ind] ()
+          {
+            base_elements[ind]
+              = std::make_pair (std::shared_ptr<FiniteElement<dim,spacedim>>(fes[i]->clone()),
+                                multiplicities[i]);
+          });
           ++ind;
         }
-    }
+    Assert(ind>0, ExcInternalError());
+
+    // wait for all of these clone operations to finish
+    clone_base_elements.join_all();
+  }
 
-  Assert(ind>0, ExcInternalError());
 
   {
     // If the system is not primitive, these have not been initialized by

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.