]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement sensible copy semantics for the Mutex class.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 22 Jan 2009 15:09:23 +0000 (15:09 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 22 Jan 2009 15:09:23 +0000 (15:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@18260 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/thread_management.h

index a7d8a66de7924d813909005295945a2f7246ab1c..a2d7efa69fbda1103ab9966f27a027d01df289eb 100644 (file)
@@ -264,7 +264,30 @@ namespace Threads
 #if DEAL_II_USE_MT == 1
 
                                   /**
-                                   * Class implementing a Mutex.
+                                   * Class implementing a
+                                   * Mutex. Mutexes are used to lock
+                                   * data structures to ensure that
+                                   * only a single thread of
+                                   * execution can access them at the
+                                   * same time.
+                                   *
+                                   * <h3>Copy semantics</h3>
+                                   *
+                                   * When copied, the receiving
+                                   * object does not receive any
+                                   * state from the object being
+                                   * copied, i.e. an entirely new
+                                   * mutex is created. This is
+                                   * consistent with expectations if
+                                   * a mutex is used as a member
+                                   * variable to lock the other
+                                   * member variables of a class: in
+                                   * that case, the mutex of the
+                                   * copied-to object should only
+                                   * guard the members of the
+                                   * copied-to object, not the
+                                   * members of both the copied-to
+                                   * and copied-from object.
                                    *
                                    * @author Wolfgang Bangerth, 2002, 2003, 2009
                                    */
@@ -328,6 +351,25 @@ namespace Threads
                                             */
           Mutex &mutex;
       };
+
+                                      /**
+                                       * Default constructor.
+                                       */
+      Mutex ()
+       {}
+
+                                      /**
+                                       * Copy constructor. As
+                                       * discussed in this class's
+                                       * documentation, no state is
+                                       * copied from the object given
+                                       * as argument.
+                                       */
+      Mutex (const Mutex &)
+                     :
+                     mutex()
+       {}
+      
       
                                       /**
                                        * Acquire a mutex.

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.