From: bangerth Date: Thu, 22 Jan 2009 15:09:23 +0000 (+0000) Subject: Implement sensible copy semantics for the Mutex class. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a793e1ff54b85d77a63475f8cacf5b77d3bd9b52;p=dealii-svn.git Implement sensible copy semantics for the Mutex class. git-svn-id: https://svn.dealii.org/trunk@18260 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/thread_management.h b/deal.II/base/include/base/thread_management.h index a7d8a66de7..a2d7efa69f 100644 --- a/deal.II/base/include/base/thread_management.h +++ b/deal.II/base/include/base/thread_management.h @@ -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. + * + *

Copy semantics

+ * + * 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.