]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Guard access to mutable variables with a mutex.
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 14 Jan 2017 05:09:48 +0000 (22:09 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 14 Jan 2017 05:09:48 +0000 (22:09 -0700)
include/deal.II/fe/fe_poly_tensor.h
source/fe/fe_poly_tensor.cc

index a754a5980bee046974a66ba08d0512b4c45f284b..517ca389972ffab73a8992bd12e820c1c2ebf88e 100644 (file)
 #define dealii__fe_poly_tensor_h
 
 
+#include <deal.II/base/config.h>
 #include <deal.II/lac/full_matrix.h>
 #include <deal.II/fe/fe.h>
 #include <deal.II/base/derivative_form.h>
 #include <deal.II/base/quadrature.h>
+#include <deal.II/base/thread_management.h>
+
 
 DEAL_II_NAMESPACE_OPEN
 
@@ -408,6 +411,11 @@ protected:
    */
   FullMatrix<double> inverse_node_matrix;
 
+  /**
+   * A mutex to be used to guard access to the variables below.
+   */
+  mutable Threads::Mutex cache_mutex;
+
   /**
    * If a shape function is computed at a single point, we must compute all of
    * them to apply #inverse_node_matrix. In order to avoid too much overhead,
index b2a6a0c9044fabd080f3dcdb75df045bfe778f91..212d9cdd93911704acfe3565fe2568fadfd76aba 100644 (file)
@@ -180,6 +180,8 @@ FE_PolyTensor<PolynomialType,dim,spacedim>::shape_value_component
   Assert (i<this->dofs_per_cell, ExcIndexRange(i,0,this->dofs_per_cell));
   Assert (component < dim, ExcIndexRange (component, 0, dim));
 
+  Threads::Mutex::ScopedLock lock (cache_mutex);
+
   if (cached_point != p || cached_values.size() == 0)
     {
       cached_point = p;
@@ -223,6 +225,8 @@ FE_PolyTensor<PolynomialType,dim,spacedim>::shape_grad_component
   Assert (i<this->dofs_per_cell, ExcIndexRange(i,0,this->dofs_per_cell));
   Assert (component < dim, ExcIndexRange (component, 0, dim));
 
+  Threads::Mutex::ScopedLock lock (cache_mutex);
+
   if (cached_point != p || cached_grads.size() == 0)
     {
       cached_point = p;
@@ -268,6 +272,8 @@ FE_PolyTensor<PolynomialType,dim,spacedim>::shape_grad_grad_component
   Assert (i<this->dofs_per_cell, ExcIndexRange(i,0,this->dofs_per_cell));
   Assert (component < dim, ExcIndexRange (component, 0, dim));
 
+  Threads::Mutex::ScopedLock lock (cache_mutex);
+
   if (cached_point != p || cached_grad_grads.size() == 0)
     {
       cached_point = p;

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.