]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Catch exceptions also in WorkStream, similar to the recent change to tasks.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 3 Jun 2013 04:25:55 +0000 (04:25 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 3 Jun 2013 04:25:55 +0000 (04:25 +0000)
git-svn-id: https://svn.dealii.org/trunk@29734 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/work_stream.h

index b44ed33f2cfbd7b3c8b9337219dff882d829d154..e43b43554e3242f750e51838830a7b6a9478997a 100644 (file)
@@ -1,7 +1,7 @@
 //---------------------------------------------------------------------------
 //    $Id$
 //
-//    Copyright (C) 2008, 2009, 2010, 2012 by the deal.II authors
+//    Copyright (C) 2008, 2009, 2010, 2012, 2013 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -344,14 +344,28 @@ namespace WorkStream
 
         ItemType *current_item = static_cast<ItemType *> (item);
 
-        // then call the worker function on
-        // each element of the chunk we
-        // were given
+        // then call the worker function on each element of the chunk we were
+        // given. since these worker functions are called on separate threads,
+        // nothing good can happen if they throw an exception and we are best
+        // off catching it and showing an error message
         for (unsigned int i=0; i<std_cxx1x::get<3>(*current_item); ++i)
-          worker (std_cxx1x::get<0>(*current_item)[i],
-                  *std_cxx1x::get<1>(*current_item),
-                  std_cxx1x::get<2>(*current_item)[i]);
-
+         {
+           try
+             {
+               worker (std_cxx1x::get<0>(*current_item)[i],
+                       *std_cxx1x::get<1>(*current_item),
+                       std_cxx1x::get<2>(*current_item)[i]);
+             }
+           catch (const std::exception &exc)
+             {
+               internal::handle_std_exception (exc);
+             }
+           catch (...)
+             {
+               internal::handle_unknown_exception ();
+             }
+         }
+       
         // then return the original pointer
         // to the now modified object
         return item;
@@ -415,9 +429,25 @@ namespace WorkStream
 
         ItemType *current_item = static_cast<ItemType *> (item);
 
-        // initiate copying data
+        // initiate copying data. for the same reasons as in the worker class
+        // above, catch exceptions rather than letting it propagate into
+        // unknown territories
         for (unsigned int i=0; i<std_cxx1x::get<3>(*current_item); ++i)
-          copier (std_cxx1x::get<2>(*current_item)[i]);
+         {
+           try
+             {
+               copier (std_cxx1x::get<2>(*current_item)[i]);
+             }
+           catch (const std::exception &exc)
+             {
+               internal::handle_std_exception (exc);
+             }
+           catch (...)
+             {
+               internal::handle_unknown_exception ();
+             }
+         }
+       
 
         // return an invalid
         // item since we are at

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.