From 013f841a718f031250d360f920419ba3632f1d1b Mon Sep 17 00:00:00 2001 From: bangerth Date: Fri, 1 Jul 2011 15:39:42 +0000 Subject: [PATCH] Add Threads::Thread::valid. git-svn-id: https://svn.dealii.org/trunk@23909 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 5 +++++ .../include/deal.II/base/thread_management.h | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 0cb92dc3c7..9839e06036 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -216,6 +216,11 @@ should be fixed now.

Specific improvements

    +
  1. New: There is now a new function Threads::Thread::valid that can be used +to query whether the thread object has been assigned a thread. +
    +(Wolfgang Bangerth 2011/07/01) +
  2. New: The new function GridGenerator::merge_triangulations can be used to compose coarse meshes from simpler ones by merging their cells into a single triangulation object. diff --git a/deal.II/include/deal.II/base/thread_management.h b/deal.II/include/deal.II/base/thread_management.h index 677a17b32b..4fe93b8e6f 100644 --- a/deal.II/include/deal.II/base/thread_management.h +++ b/deal.II/include/deal.II/base/thread_management.h @@ -1524,11 +1524,13 @@ namespace Threads * have used the default * constructor of this class * and have not assigned a - * thread object to it. + * thread object to it (i.e. if + * the valid() function would + * return false). */ void join () const { - AssertThrow (thread_descriptor, ExcNoThread()); + AssertThrow (valid(), ExcNoThread()); thread_descriptor->join (); } @@ -1546,6 +1548,18 @@ namespace Threads return thread_descriptor->ret_val.get(); } + /** + * Return true if this object + * has had a thread associated + * with it, either by using the + * non-default constructor or + * by assignment. + */ + bool valid () const + { + return static_cast(thread_descriptor); + } + /** * Check for equality of thread -- 2.39.5