From: Wolfgang Bangerth Date: Mon, 3 Jun 2013 04:25:55 +0000 (+0000) Subject: Catch exceptions also in WorkStream, similar to the recent change to tasks. X-Git-Tag: v8.0.0~327 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c2cab6d90175b482224cee29bc478e670db3a4e;p=dealii.git Catch exceptions also in WorkStream, similar to the recent change to tasks. git-svn-id: https://svn.dealii.org/trunk@29734 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/work_stream.h b/deal.II/include/deal.II/base/work_stream.h index b44ed33f2c..e43b43554e 100644 --- a/deal.II/include/deal.II/base/work_stream.h +++ b/deal.II/include/deal.II/base/work_stream.h @@ -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 (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(*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 (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(*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