]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Split a mutex into two that each guard one set of variables. 16188/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 25 Oct 2023 16:14:07 +0000 (10:14 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 25 Oct 2023 16:14:07 +0000 (10:14 -0600)
include/deal.II/fe/fe_dgq.h
include/deal.II/fe/fe_nedelec.h
include/deal.II/fe/fe_q_base.h
include/deal.II/fe/fe_raviart_thomas.h
include/deal.II/fe/fe_simplex_p.h
source/fe/fe_dgq.cc
source/fe/fe_nedelec.cc
source/fe/fe_q_base.cc
source/fe/fe_raviart_thomas_nodal.cc
source/fe/fe_simplex_p.cc

index 25ae1700d188355e05e111c8e000e180ebaef058..3ff5f3b91c923cbaa4372d235e8f3fcde905cba4 100644 (file)
@@ -367,10 +367,12 @@ private:
   rotate_indices(std::vector<unsigned int> &indices,
                  const char                 direction) const;
 
-  /*
-   * Mutex for protecting initialization of restriction and embedding matrix.
+  /**
+   * Mutex variables used for protecting the initialization of restriction
+   * and embedding matrices.
    */
-  mutable Threads::Mutex mutex;
+  mutable Threads::Mutex restriction_matrix_mutex;
+  mutable Threads::Mutex prolongation_matrix_mutex;
 
   // Allow access from other dimensions.
   template <int dim1, int spacedim1>
index f508c432dc4befc902043b95efaba96dab3b8d22..e02f7a1e5ad7e5a3c05655f98568f77449c1d74c 100644 (file)
@@ -636,9 +636,11 @@ private:
   Table<2, double> boundary_weights;
 
   /**
-   * Mutex for protecting initialization of restriction and embedding matrix.
+   * Mutex variables used for protecting the initialization of restriction
+   * and embedding matrices.
    */
-  mutable Threads::Mutex mutex;
+  mutable Threads::Mutex restriction_matrix_mutex;
+  mutable Threads::Mutex prolongation_matrix_mutex;
 
   /**
    * Initialize the permutation pattern and the pattern of sign change.
index 3ffe31978baa4d19e1cff8147339800fd6953c40..6eb213aa448dd07846712341cd0b754f9361d5d7 100644 (file)
@@ -334,9 +334,11 @@ protected:
 
 private:
   /**
-   * Mutex for protecting initialization of restriction and embedding matrix.
+   * Mutex variables used for protecting the initialization of restriction
+   * and embedding matrices.
    */
-  mutable Threads::Mutex mutex;
+  mutable Threads::Mutex restriction_matrix_mutex;
+  mutable Threads::Mutex prolongation_matrix_mutex;
 
   /**
    * The highest polynomial degree of the underlying tensor product space
index f2b64679d593969f97ac38b739ebadc01913d94f..1feb6189512fec5fa318afefd8c56948d94d8855 100644 (file)
@@ -417,10 +417,12 @@ private:
   void
   initialize_quad_dof_index_permutation_and_sign_change();
 
-  /*
-   * Mutex for protecting initialization of restriction and embedding matrix.
+  /**
+   * Mutex variables used for protecting the initialization of restriction
+   * and embedding matrices.
    */
-  mutable Threads::Mutex mutex;
+  mutable Threads::Mutex restriction_matrix_mutex;
+  mutable Threads::Mutex prolongation_matrix_mutex;
 };
 
 /** @} */
index 8d92463cf8ae812a2b753d739071b38f6b693fd9..8e2dbdfb2d8e6af4e7768c80ff0f50ce2a228752 100644 (file)
@@ -108,11 +108,13 @@ public:
     const std::vector<Vector<double>> &support_point_values,
     std::vector<double>               &nodal_values) const override;
 
-protected:
+private:
   /**
-   * Mutex used to guard computation of some internal lookup tables.
+   * Mutex variables used for protecting the initialization of restriction
+   * and embedding matrices.
    */
-  mutable Threads::Mutex mutex;
+  mutable Threads::Mutex restriction_matrix_mutex;
+  mutable Threads::Mutex prolongation_matrix_mutex;
 };
 
 
index ade082048e1176694b560d1f43e3489ec80e029f..d34e6b4c73b60ebc4798dd333e1251e6037a9f6a 100644 (file)
@@ -421,7 +421,7 @@ FE_DGQ<dim, spacedim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(prolongation_matrix_mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -497,7 +497,7 @@ FE_DGQ<dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(restriction_matrix_mutex);
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index a1038ec5ee8cbf13871bd113d691861f3c7226a4..674082578bcfc8d8474b0c9819df4708db45f38d 100644 (file)
@@ -3041,7 +3041,7 @@ FE_Nedelec<dim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(prolongation_matrix_mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -3097,7 +3097,7 @@ FE_Nedelec<dim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(restriction_matrix_mutex);
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index 09e453e41adb659db2e6bb316266ae4759e33b69..55e995a8eec8af4790a3ea48c9b7b49603d02b52 100644 (file)
@@ -1266,7 +1266,7 @@ FE_Q_Base<dim, spacedim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(prolongation_matrix_mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -1465,7 +1465,7 @@ FE_Q_Base<dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(restriction_matrix_mutex);
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index f00b69c3958214019cba9f7437b16e22a397800b..4e616a2b02741e6e05467fb27b5a3262d16ac53e 100644 (file)
@@ -683,7 +683,7 @@ FE_RaviartThomasNodal<dim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(prolongation_matrix_mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -741,7 +741,7 @@ FE_RaviartThomasNodal<dim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(restriction_matrix_mutex);
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index 767d5b1ab503a5e98ad13903221c671955d97b15..54d9000af9ab123b59e49677b30062825f9f7684 100644 (file)
@@ -366,7 +366,7 @@ FE_SimplexPoly<dim, spacedim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(prolongation_matrix_mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -408,7 +408,7 @@ FE_SimplexPoly<dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      std::lock_guard<std::mutex> lock(this->mutex);
+      std::lock_guard<std::mutex> lock(restriction_matrix_mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->restriction[refinement_case - 1][child].n() ==

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.