]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Provide external lock.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 14 Nov 2001 18:01:04 +0000 (18:01 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 14 Nov 2001 18:01:04 +0000 (18:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@5206 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_direct.h
deal.II/lac/source/sparse_direct.cc

index 1d459d9934ba24e09a4d4bd36155187a1532e1d8..494be4d3b56a6fad1ea50f4b6bc5b01b64b2e081 100644 (file)
@@ -18,6 +18,7 @@
 #include <base/config.h>
 #include <base/exceptions.h>
 #include <base/subscriptor.h>
+#include <base/thread_management.h>
 #include <lac/vector.h>
 #include <lac/sparse_matrix.h>
 
  * active. You have to synchronise your calls to the functions
  * provided by this class using mutexes (see the @ref{Threads}
  * namespace for such classes) to avoid multiple active calls at the
- * same time if you use multithreading.
+ * same time if you use multithreading. Since you may use this class
+ * in different parts of your program, and may not want to use a
+ * global variable for locking, this class has a lock as static member
+ * variable, which may be accessed using the
+ * @p{get_synchronisation_lock} function. Note however, that this
+ * class does not perform the synchronisation for you within its
+ * member functions. The reason is that you will usually want to
+ * synchronise over the calls to @p{initialize} and @p{factorize},
+ * since there should probably not be a call to one of these function
+ * with another matrix between the calls for one matrix. (The author
+ * does not really know whether this is true, but it is probably safe
+ * to assume that.) Since such cross-function synchronisation can only
+ * be performed from outside, it is left to the user of this class to
+ * do so.
  *
  * @author Wolfgang Bangerth, 2000, 2001
  */
@@ -211,6 +225,16 @@ class SparseDirectMA27 : public Subscriptor
                                      */
     unsigned int memory_consumption () const;
     
+                                    /**
+                                     * Get a reference to the
+                                     * synchronisation lock which can
+                                     * be used for this class. See
+                                     * the general description of
+                                     * this class for more
+                                     * information.
+                                     */
+    Threads::ThreadMutex & get_synchronisation_lock () const;
+
                                     /**
                                      * Exception.
                                      */
@@ -341,6 +365,12 @@ class SparseDirectMA27 : public Subscriptor
                                      */
     int IFLAG;
 
+                                    /**
+                                     * Mutex for synchronising access
+                                     * to this class.
+                                     */
+    static Threads::ThreadMutex synchronisation_lock;
+    
                                     /**
                                      * Fill the @p{A} array from the
                                      * symmetric part of the given
@@ -400,7 +430,20 @@ class SparseDirectMA27 : public Subscriptor
  * active. You have to synchronise your calls to the functions
  * provided by this class using mutexes (see the @ref{Threads}
  * namespace for such classes) to avoid multiple active calls at the
- * same time if you use multithreading.
+ * same time if you use multithreading. Since you may use this class
+ * in different parts of your program, and may not want to use a
+ * global variable for locking, this class has a lock as static member
+ * variable, which may be accessed using the
+ * @p{get_synchronisation_lock} function. Note however, that this
+ * class does not perform the synchronisation for you within its
+ * member functions. The reason is that you will usually want to
+ * synchronise over the calls to @p{initialize} and @p{factorize},
+ * since there should probably not be a call to one of these function
+ * with another matrix between the calls for one matrix. (The author
+ * does not really know whether this is true, but it is probably safe
+ * to assume that.) Since such cross-function synchronisation can only
+ * be performed from outside, it is left to the user of this class to
+ * do so.
  *
  * @author Wolfgang Bangerth, 2000, 2001
  */
@@ -517,6 +560,16 @@ class SparseDirectMA47 : public Subscriptor
                                      */
     unsigned int memory_consumption () const;
 
+                                    /**
+                                     * Get a reference to the
+                                     * synchronisation lock which can
+                                     * be used for this class. See
+                                     * the general description of
+                                     * this class for more
+                                     * information.
+                                     */
+    Threads::ThreadMutex & get_synchronisation_lock () const;
+    
                                     /**
                                      * Exception.
                                      */
@@ -640,6 +693,12 @@ class SparseDirectMA47 : public Subscriptor
     std::vector<unsigned int> KEEP;
     std::vector<unsigned int> IW1;
 
+                                    /**
+                                     * Mutex for synchronising access
+                                     * to this class.
+                                     */
+    static Threads::ThreadMutex synchronisation_lock;
+    
                                     /**
                                      * Fill the @p{A} array from the
                                      * symmetric part of the given
index b91f9cf41a60e86abef40b9e4cdfd960fa39bb7d..822196c27c3086ac1210826de4d838827384213f 100644 (file)
@@ -195,6 +195,9 @@ namespace HSL
 /* -------------------------- MA27 ---------------------------- */
 
 
+Threads::ThreadMutex SparseDirectMA27::synchronisation_lock;
+
+
 SparseDirectMA27::SparseDirectMA27 (const double LIW_factor_1,
                                    const double LIW_factor_2,
                                    const double LA_factor,
@@ -503,6 +506,14 @@ SparseDirectMA27::memory_consumption () const
 
 
 
+Threads::ThreadMutex &
+SparseDirectMA27::get_synchronisation_lock () const
+{
+  return synchronisation_lock;
+};
+
+
+
 void
 SparseDirectMA27::fill_A (const SparseMatrix<double> &matrix)
 {
@@ -535,7 +546,7 @@ SparseDirectMA27::fill_A (const SparseMatrix<double> &matrix)
 
 /* -------------------------- MA47 ---------------------------- */
 
-
+Threads::ThreadMutex SparseDirectMA47::synchronisation_lock;
 
 
 SparseDirectMA47::SparseDirectMA47 (const double LIW_factor_1,
@@ -832,6 +843,14 @@ SparseDirectMA47::memory_consumption () const
 
 
 
+Threads::ThreadMutex &
+SparseDirectMA47::get_synchronisation_lock () const
+{
+  return synchronisation_lock;
+};
+
+
+
 void
 SparseDirectMA47::fill_A (const SparseMatrix<double> &matrix)
 {

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.