]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add Threads::Thread::valid.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Jul 2011 15:39:42 +0000 (15:39 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Jul 2011 15:39:42 +0000 (15:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@23909 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/base/thread_management.h

index 0cb92dc3c7ae065cfe03f6049edde8cc1c93fb71..9839e060362d13f5eef4f9d498692fe113680af1 100644 (file)
@@ -216,6 +216,11 @@ should be fixed now.
 <h3>Specific improvements</h3>
 
 <ol>
+<li> 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.
+<br>
+(Wolfgang Bangerth 2011/07/01)
+
 <li> 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.
index 677a17b32b64014655132cd3e8ee7f37e8e155d5..4fe93b8e6f55dce221a26c9b9cae241b18dcf11f 100644 (file)
@@ -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<bool>(thread_descriptor);
+       }
+
 
                                        /**
                                         * Check for equality of thread

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.