]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Replace uses of Threads::Mutex::ScopedLock by std::lock_guard.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 27 Sep 2018 13:30:22 +0000 (07:30 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 27 Sep 2018 13:30:22 +0000 (07:30 -0600)
37 files changed:
include/deal.II/base/logstream.h
include/deal.II/fe/fe_tools.templates.h
include/deal.II/lac/block_matrix_base.h
include/deal.II/lac/la_parallel_vector.templates.h
include/deal.II/lac/precondition.h
include/deal.II/lac/swappable_vector.templates.h
include/deal.II/lac/tensor_product_matrix.h
include/deal.II/lac/vector_memory.templates.h
include/deal.II/matrix_free/dof_info.templates.h
source/base/flow_function.cc
source/base/function_cspline.cc
source/base/function_parser.cc
source/base/index_set.cc
source/base/logstream.cc
source/base/parallel.cc
source/base/polynomial.cc
source/base/polynomials_abf.cc
source/base/polynomials_bdm.cc
source/base/polynomials_raviart_thomas.cc
source/base/polynomials_rt_bubbles.cc
source/base/timer.cc
source/fe/fe_dgq.cc
source/fe/fe_nedelec.cc
source/fe/fe_poly_tensor.cc
source/fe/fe_q_base.cc
source/fe/fe_system.cc
source/fe/mapping_fe_field.cc
source/fe/mapping_q_eulerian.cc
source/lac/lapack_full_matrix.cc
source/lac/scalapack.cc
tests/base/thread_local_storage_01.cc
tests/base/thread_local_storage_02.cc
tests/bits/step-13.cc
tests/bits/step-14.cc
tests/fail/hp-step-14.cc
tests/hp/step-13.cc
tests/numerics/time_dependent_01.cc

index ed62db3590d7c61a04d33c9d26f99fdce7eef3cf..bdff40fa325bdb1c2dd7ccd99d4a80aa10ba5ded 100644 (file)
@@ -97,7 +97,7 @@ public:
    * <code>throw</code>, or by simply reaching the closing brace. In all of
    * these cases, it is not necessary to remember to pop the prefix manually
    * using LogStream::pop(). In this, it works just like the better known
-   * std::unique_ptr and Threads::Mutex::ScopedLock classes.
+   * std::unique_ptr and std::lock_guard classes.
    */
   class Prefix
   {
index fd3c7a0bc75759dd1794f480beef7305d30bfe69..c741bc0c245c36e98688607c082b0c3a0eb4e24d 100644 (file)
@@ -2409,7 +2409,7 @@ namespace FETools
     // operation of this function;
     // for this, acquire the lock
     // until we quit this function
-    Threads::Mutex::ScopedLock lock(
+    std::lock_guard<std::mutex> lock(
       internal::FEToolsAddFENameHelper::fe_name_map_lock);
 
     Assert(
@@ -2566,7 +2566,7 @@ namespace FETools
           {
             // Make sure no other thread
             // is just adding an element
-            Threads::Mutex::ScopedLock lock(
+            std::lock_guard<std::mutex> lock(
               internal::FEToolsAddFENameHelper::fe_name_map_lock);
             AssertThrow(fe_name_map.find(name_part) != fe_name_map.end(),
                         FETools::ExcInvalidFEName(name));
index a12cec0ddc626ec0fcb0e9fea2ab307488b4e370..13c9b4a335cf688e6f7f33e5ea80d69c8da85bd2 100644 (file)
@@ -1724,7 +1724,7 @@ BlockMatrixBase<MatrixType>::set(const size_type  row,
 
   // lock access to the temporary data structure to
   // allow multiple threads to call this function concurrently
-  Threads::Mutex::ScopedLock lock(temporary_data.mutex);
+  std::lock_guard<std::mutex> lock(temporary_data.mutex);
 
   // Resize scratch arrays
   if (temporary_data.column_indices.size() < this->n_block_cols())
@@ -1981,7 +1981,7 @@ BlockMatrixBase<MatrixType>::add(const size_type  row,
     }
 
   // Lock scratch arrays, then resize them
-  Threads::Mutex::ScopedLock lock(temporary_data.mutex);
+  std::lock_guard<std::mutex> lock(temporary_data.mutex);
 
   if (temporary_data.column_indices.size() < this->n_block_cols())
     {
index 6b297418e2cbc0ce214697fb4cb6bba69b202c0a..f008b8ce53e3cab666b3899d0047bb534f9d8d3e 100644 (file)
@@ -875,7 +875,7 @@ namespace LinearAlgebra
 
 #ifdef DEAL_II_WITH_MPI
       // make this function thread safe
-      Threads::Mutex::ScopedLock lock(mutex);
+      std::lock_guard<std::mutex> lock(mutex);
 
       // allocate import_data in case it is not set up yet
       if (import_data == nullptr && partitioner->n_import_indices() > 0)
@@ -928,7 +928,7 @@ namespace LinearAlgebra
       // compress_requests.size() == 0
 
       // make this function thread safe
-      Threads::Mutex::ScopedLock lock(mutex);
+      std::lock_guard<std::mutex> lock(mutex);
 
       Assert(partitioner->n_import_indices() == 0 || import_data != nullptr,
              ExcNotInitialized());
@@ -975,7 +975,7 @@ namespace LinearAlgebra
         return;
 
       // make this function thread safe
-      Threads::Mutex::ScopedLock lock(mutex);
+      std::lock_guard<std::mutex> lock(mutex);
 
       // allocate import_data in case it is not set up yet
       if (import_data == nullptr && partitioner->n_import_indices() > 0)
@@ -1033,7 +1033,7 @@ namespace LinearAlgebra
       if (update_ghost_values_requests.size() > 0)
         {
           // make this function thread safe
-          Threads::Mutex::ScopedLock lock(mutex);
+          std::lock_guard<std::mutex> lock(mutex);
 
           partitioner->export_to_ghosted_array_finish(
             ArrayView<Number>(data.values.get() + partitioner->local_size(),
index 96f2e06aef52296a8fd3ec44cb50a84b4918073f..45bdb20c1353fb2c8f0121c6e09250e0d745a344 100644 (file)
@@ -2308,7 +2308,7 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::vmult(
   VectorType &      dst,
   const VectorType &src) const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
@@ -2334,7 +2334,7 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::Tvmult(
   VectorType &      dst,
   const VectorType &src) const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
@@ -2360,7 +2360,7 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::step(
   VectorType &      dst,
   const VectorType &src) const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
@@ -2387,7 +2387,7 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::Tstep(
   VectorType &      dst,
   const VectorType &src) const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   if (eigenvalues_are_initialized == false)
     estimate_eigenvalues(src);
 
index 5b109df84a180228980a730aefae76eb7a525187..bd0bed841453ddaa2f0bffe677a9f7f06d8be672 100644 (file)
@@ -78,7 +78,7 @@ SwappableVector<number>::operator=(const SwappableVector<number> &v)
   // if in MT mode, block all other
   // operations. if not in MT mode,
   // this is a no-op
-  Threads::Mutex::ScopedLock lock(this->lock);
+  std::lock_guard<std::mutex> lock(this->lock);
 
   Vector<number>::operator=(v);
   data_is_preloaded       = false;
@@ -107,7 +107,7 @@ SwappableVector<number>::swap_out(const std::string &name)
   // if in MT mode, block all other
   // operations. if not in MT mode,
   // this is a no-op
-  Threads::Mutex::ScopedLock lock(this->lock);
+  std::lock_guard<std::mutex> lock(this->lock);
 
   //  check that we have not called
   //  @p alert without the respective
@@ -225,7 +225,7 @@ SwappableVector<number>::kill_file()
   // (there should be none, but who
   // knows). if not in MT mode,
   // this is a no-op
-  Threads::Mutex::ScopedLock lock(this->lock);
+  std::lock_guard<std::mutex> lock(this->lock);
 
   // this is too bad: someone
   // requested the vector in advance,
index 3a86de7c08f3db8900369900e97808b3d67478b5..53fcb039f15e3212af85f599da3fc2142e6d1d2a 100644 (file)
@@ -477,8 +477,8 @@ TensorProductMatrixSymmetricSumBase<dim, Number, size>::vmult(
 {
   AssertDimension(dst_view.size(), this->m());
   AssertDimension(src_view.size(), this->n());
-  Threads::Mutex::ScopedLock lock(this->mutex);
-  const unsigned int         n =
+  std::lock_guard<std::mutex> lock(this->mutex);
+  const unsigned int          n =
     Utilities::fixed_power<dim>(size > 0 ? size : eigenvalues[0].size());
   tmp_array.resize_fast(n * 2);
   constexpr int kernel_size = size > 0 ? size : 0;
@@ -545,8 +545,8 @@ TensorProductMatrixSymmetricSumBase<dim, Number, size>::apply_inverse(
 {
   AssertDimension(dst_view.size(), this->n());
   AssertDimension(src_view.size(), this->m());
-  Threads::Mutex::ScopedLock lock(this->mutex);
-  const unsigned int         n = size > 0 ? size : eigenvalues[0].size();
+  std::lock_guard<std::mutex> lock(this->mutex);
+  const unsigned int          n = size > 0 ? size : eigenvalues[0].size();
   tmp_array.resize_fast(Utilities::fixed_power<dim>(n));
   constexpr int kernel_size = size > 0 ? size : 0;
   internal::EvaluatorTensorProduct<internal::evaluate_general,
index 87cebfc211a77764e33daac3a1d0eff83e1fa5ad..20412b74805905a560dec84bc99ac1ebf0e37607 100644 (file)
@@ -81,7 +81,7 @@ inline GrowingVectorMemory<VectorType>::GrowingVectorMemory(
   , current_alloc(0)
   , log_statistics(log_statistics)
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   pool.initialize(initial_size);
 }
 
@@ -106,7 +106,7 @@ template <typename VectorType>
 inline VectorType *
 GrowingVectorMemory<VectorType>::alloc()
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   ++total_alloc;
   ++current_alloc;
@@ -136,7 +136,7 @@ template <typename VectorType>
 inline void
 GrowingVectorMemory<VectorType>::free(const VectorType *const v)
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   for (typename std::vector<entry_type>::iterator i = pool.data->begin();
        i != pool.data->end();
@@ -158,7 +158,7 @@ template <typename VectorType>
 inline void
 GrowingVectorMemory<VectorType>::release_unused_memory()
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   if (pool.data != nullptr)
     pool.data->clear();
@@ -170,7 +170,7 @@ template <typename VectorType>
 inline std::size_t
 GrowingVectorMemory<VectorType>::memory_consumption() const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   std::size_t                                            result = sizeof(*this);
   const typename std::vector<entry_type>::const_iterator end = pool.data->end();
index b46c0e91e4390f0bec5dff409374bf1606a2e507..a3400b2b506a01db4bf42de0ba140dce3bc52b1b 100644 (file)
@@ -1313,7 +1313,7 @@ namespace internal
                 // that are within the range of one lock at once
                 const unsigned int next_bucket =
                   (*it / bucket_size_threading + 1) * bucket_size_threading;
-                Threads::Mutex::ScopedLock lock(
+                std::lock_guard<std::mutex> lock(
                   mutexes[*it / bucket_size_threading]);
                 for (; it != end_unique && *it < next_bucket; ++it)
                   {
@@ -1351,7 +1351,7 @@ namespace internal
               {
                 const unsigned int next_bucket =
                   (*it / bucket_size_threading + 1) * bucket_size_threading;
-                Threads::Mutex::ScopedLock lock(
+                std::lock_guard<std::mutex> lock(
                   mutexes[*it / bucket_size_threading]);
                 for (; it != end_unique && *it < next_bucket; ++it)
                   if (row_lengths[*it] > 0)
index 0e192f005d14304fb6d1fa667e03e47ad0e3c1d0..8dae6dc072a8039c632e50998775a9f136bd0a0d 100644 (file)
@@ -57,7 +57,7 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
-    Threads::Mutex::ScopedLock lock(mutex);
+    std::lock_guard<std::mutex> lock(mutex);
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
@@ -87,7 +87,7 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
-    Threads::Mutex::ScopedLock lock(mutex);
+    std::lock_guard<std::mutex> lock(mutex);
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
@@ -110,7 +110,7 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
-    Threads::Mutex::ScopedLock lock(mutex);
+    std::lock_guard<std::mutex> lock(mutex);
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
@@ -132,7 +132,7 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
-    Threads::Mutex::ScopedLock lock(mutex);
+    std::lock_guard<std::mutex> lock(mutex);
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_gradients[d].resize(n_points);
@@ -160,7 +160,7 @@ namespace Functions
 
     // guard access to the aux_*
     // variables in multithread mode
-    Threads::Mutex::ScopedLock lock(mutex);
+    std::lock_guard<std::mutex> lock(mutex);
 
     for (unsigned int d = 0; d < dim + 1; ++d)
       aux_values[d].resize(n_points);
index 3391d9b2d2aafd731d82d191e29ed489b232dfad..cdc9972c4942514f319cc93be2099f377c75d164 100644 (file)
@@ -73,7 +73,7 @@ namespace Functions
     // GSL functions may modify gsl_interp_accel *acc object (last argument).
     // This can only work in multithreaded applications if we lock the data
     // structures via a mutex.
-    Threads::Mutex::ScopedLock lock(acc_mutex);
+    std::lock_guard<std::mutex> lock(acc_mutex);
 
     const double x = p[0];
     Assert(x >= interpolation_points.front() &&
@@ -94,7 +94,7 @@ namespace Functions
     // GSL functions may modify gsl_interp_accel *acc object (last argument).
     // This can only work in multithreaded applications if we lock the data
     // structures via a mutex.
-    Threads::Mutex::ScopedLock lock(acc_mutex);
+    std::lock_guard<std::mutex> lock(acc_mutex);
 
     const double x = p[0];
     Assert(x >= interpolation_points.front() &&
@@ -118,7 +118,7 @@ namespace Functions
     // GSL functions may modify gsl_interp_accel *acc object (last argument).
     // This can only work in multithreaded applications if we lock the data
     // structures via a mutex.
-    Threads::Mutex::ScopedLock lock(acc_mutex);
+    std::lock_guard<std::mutex> lock(acc_mutex);
 
     const double x = p[0];
     Assert(x >= interpolation_points.front() &&
index 24a63b19d5cd25eed729be626d3fe5e05143541d..769c681851adb60cd2adad0491c7c0a709f6dbdd 100644 (file)
@@ -241,8 +241,8 @@ namespace internal
   double
   mu_rand_seed(double seed)
   {
-    static Threads::Mutex      rand_mutex;
-    Threads::Mutex::ScopedLock lock(rand_mutex);
+    static Threads::Mutex       rand_mutex;
+    std::lock_guard<std::mutex> lock(rand_mutex);
 
     static boost::random::uniform_real_distribution<> uniform_distribution(0,
                                                                            1);
@@ -262,7 +262,7 @@ namespace internal
   mu_rand()
   {
     static Threads::Mutex                             rand_mutex;
-    Threads::Mutex::ScopedLock                        lock(rand_mutex);
+    std::lock_guard<std::mutex>                       lock(rand_mutex);
     static boost::random::uniform_real_distribution<> uniform_distribution(0,
                                                                            1);
     static boost::random::mt19937                     rng(
index 9b5fa12d277f670c3758854d1b92ab69a31e081b..5a491e5f7aa60dff4ef971755ffaeb5bcbdda8cd 100644 (file)
@@ -129,7 +129,7 @@ IndexSet::do_compress() const
   // via a mutex, so that users can call 'const' functions from threads
   // in parallel (and these 'const' functions can then call compress()
   // which itself calls the current function)
-  Threads::Mutex::ScopedLock lock(compress_mutex);
+  std::lock_guard<std::mutex> lock(compress_mutex);
 
   // see if any of the contiguous ranges can be merged. do not use
   // std::vector::erase in-place as it is quadratic in the number of
index ccdb9a4ab01407d910dcd0165990e20cf53d0a91..c1c97a33798ca7324794d12384ab219e501ff84a 100644 (file)
@@ -191,7 +191,7 @@ LogStream::operator<<(std::ostream &(*p)(std::ostream &))
 
   if (query_streambuf.flushed())
     {
-      Threads::Mutex::ScopedLock lock(write_lock);
+      std::lock_guard<std::mutex> lock(write_lock);
 
       // Print the line head in case of a previous newline:
       if (at_newline)
@@ -218,7 +218,7 @@ LogStream::attach(std::ostream &                o,
                   const bool                    print_job_id,
                   const std::ios_base::fmtflags flags)
 {
-  Threads::Mutex::ScopedLock lock(log_lock);
+  std::lock_guard<std::mutex> lock(log_lock);
   file = &o;
   o.setf(flags);
   if (print_job_id)
@@ -229,7 +229,7 @@ LogStream::attach(std::ostream &                o,
 void
 LogStream::detach()
 {
-  Threads::Mutex::ScopedLock lock(log_lock);
+  std::lock_guard<std::mutex> lock(log_lock);
   file = nullptr;
 }
 
@@ -347,9 +347,9 @@ LogStream::width(const std::streamsize wide)
 unsigned int
 LogStream::depth_console(const unsigned int n)
 {
-  Threads::Mutex::ScopedLock lock(log_lock);
-  const unsigned int         h = std_depth;
-  std_depth                    = n;
+  std::lock_guard<std::mutex> lock(log_lock);
+  const unsigned int          h = std_depth;
+  std_depth                     = n;
   return h;
 }
 
@@ -358,9 +358,9 @@ LogStream::depth_console(const unsigned int n)
 unsigned int
 LogStream::depth_file(const unsigned int n)
 {
-  Threads::Mutex::ScopedLock lock(log_lock);
-  const unsigned int         h = file_depth;
-  file_depth                   = n;
+  std::lock_guard<std::mutex> lock(log_lock);
+  const unsigned int          h = file_depth;
+  file_depth                    = n;
   return h;
 }
 
@@ -369,9 +369,9 @@ LogStream::depth_file(const unsigned int n)
 bool
 LogStream::log_thread_id(const bool flag)
 {
-  Threads::Mutex::ScopedLock lock(log_lock);
-  const bool                 h = print_thread_id;
-  print_thread_id              = flag;
+  std::lock_guard<std::mutex> lock(log_lock);
+  const bool                  h = print_thread_id;
+  print_thread_id               = flag;
   return h;
 }
 
index e448c07b6a761bcaa26852f28a8e758c6e12b1e1..da998a6fe68c152a9a7c850936068a9cd25bd27c 100644 (file)
@@ -74,7 +74,7 @@ namespace parallel
     std::shared_ptr<tbb::affinity_partitioner>
     TBBPartitioner::acquire_one_partitioner()
     {
-      dealii::Threads::Mutex::ScopedLock lock(mutex);
+      std::lock_guard<std::mutex> lock(mutex);
       if (in_use)
         return std::make_shared<tbb::affinity_partitioner>();
 
@@ -90,7 +90,7 @@ namespace parallel
     {
       if (p.get() == my_partitioner.get())
         {
-          dealii::Threads::Mutex::ScopedLock lock(mutex);
+          std::lock_guard<std::mutex> lock(mutex);
           in_use = false;
         }
     }
index eca63433ca866aa42d56265162ed92e9b68905ce..8a9cbc1131b9a15a807590222928a8722e8c73b3 100644 (file)
@@ -1006,7 +1006,7 @@ namespace Polynomials
     // of this function
     // for this, acquire the lock
     // until we quit this function
-    Threads::Mutex::ScopedLock lock(coefficients_lock);
+    std::lock_guard<std::mutex> lock(coefficients_lock);
 
     // The first 2 coefficients
     // are hard-coded
@@ -1140,7 +1140,7 @@ namespace Polynomials
     // then get a pointer to the array
     // of coefficients. do that in a MT
     // safe way
-    Threads::Mutex::ScopedLock lock(coefficients_lock);
+    std::lock_guard<std::mutex> lock(coefficients_lock);
     return *recursive_coefficients[k];
   }
 
index e52d5001b69634ff12f3c556425114a0538f9500..b8ca149a93f0c3f4056f217f9dd0aece411c9733 100644 (file)
@@ -86,7 +86,7 @@ PolynomialsABF<dim>::compute(
   // using a mutex to make sure they
   // are not used by multiple threads
   // at once
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   p_values.resize((values.size() == 0) ? 0 : n_sub);
   p_grads.resize((grads.size() == 0) ? 0 : n_sub);
index bb14979d3bc04ad104aeb0070354b901143e4536..51491c0a0b4e3a86183f4f6d567aa938e8b4055d 100644 (file)
@@ -85,7 +85,7 @@ PolynomialsBDM<dim>::compute(
   // are not used by multiple threads
   // at once
   {
-    Threads::Mutex::ScopedLock lock(mutex);
+    std::lock_guard<std::mutex> lock(mutex);
 
     p_values.resize((values.size() == 0) ? 0 : n_sub);
     p_grads.resize((grads.size() == 0) ? 0 : n_sub);
index 6b4bd50a826dfa65ca83cfaa1ccdf6f6669e125a..8bf74e98817e4d30026fda9b631eff3bfe922c46 100644 (file)
@@ -93,8 +93,8 @@ PolynomialsRaviartThomas<dim>::compute(
   // deal.II/create_mass_matrix_05)
   // will start to produce random
   // results in multithread mode
-  static Threads::Mutex      mutex;
-  Threads::Mutex::ScopedLock lock(mutex);
+  static Threads::Mutex       mutex;
+  std::lock_guard<std::mutex> lock(mutex);
 
   static std::vector<double>         p_values;
   static std::vector<Tensor<1, dim>> p_grads;
index b79ef3ee3ea6016da8b21d66be1095a43a81d403..117d244723462c7738e2a9d7a50b17cc9b8c49ac 100644 (file)
@@ -73,8 +73,8 @@ PolynomialsRT_Bubbles<dim>::compute(
   // using a mutex to make sure they are not used by multiple threads
   // at once
   {
-    static Threads::Mutex      mutex;
-    Threads::Mutex::ScopedLock lock(mutex);
+    static Threads::Mutex       mutex;
+    std::lock_guard<std::mutex> lock(mutex);
 
     static std::vector<Tensor<1, dim>> p_values;
     static std::vector<Tensor<2, dim>> p_grads;
index 007f9dd017d67a35afebfddf28c411b44e7abcad..e2a1fba761ffbff27fb9f8f07f2384673a996354 100644 (file)
@@ -412,7 +412,7 @@ TimerOutput::~TimerOutput()
 void
 TimerOutput::enter_subsection(const std::string &section_name)
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   Assert(section_name.empty() == false, ExcMessage("Section string is empty."));
 
@@ -457,7 +457,7 @@ TimerOutput::leave_subsection(const std::string &section_name)
   Assert(!active_sections.empty(),
          ExcMessage("Cannot exit any section because none has been entered!"));
 
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   if (section_name != "")
     {
@@ -873,7 +873,7 @@ TimerOutput::enable_output()
 void
 TimerOutput::reset()
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   sections.clear();
   active_sections.clear();
   timer_all.restart();
index 65bbd6f8d301dea92154d3f164eb2616281cac7f..439fb5d7b5a783aa3c7de0f1bdbfa736b7e0056b 100644 (file)
@@ -408,7 +408,7 @@ FE_DGQ<dim, spacedim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -488,7 +488,7 @@ FE_DGQ<dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index 06139b146b5946e4ec3a8db3dae383bb3372584c..51f5fe7515b7f0484f2117821d73c78218fffa51 100644 (file)
@@ -2985,7 +2985,7 @@ FE_Nedelec<dim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -3047,7 +3047,7 @@ FE_Nedelec<dim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index ae9506d861783f9f025f5db6de9beed799a6a8d6..2dc68bc749b933fb966a3400e0926f47b5df838f 100644 (file)
@@ -201,7 +201,7 @@ 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);
+  std::lock_guard<std::mutex> lock(cache_mutex);
 
   if (cached_point != p || cached_values.size() == 0)
     {
@@ -247,7 +247,7 @@ 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);
+  std::lock_guard<std::mutex> lock(cache_mutex);
 
   if (cached_point != p || cached_grads.size() == 0)
     {
@@ -294,7 +294,7 @@ 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);
+  std::lock_guard<std::mutex> lock(cache_mutex);
 
   if (cached_point != p || cached_grad_grads.size() == 0)
     {
index 93590f38f090985285d7556cdd26ad8bf560161e..fd4f429c2293f5f9beb6006e1c53567e456a54d4 100644 (file)
@@ -1232,7 +1232,7 @@ FE_Q_Base<PolynomialType, dim, spacedim>::get_prolongation_matrix(
   // initialization upon first request
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       // if matrix got updated while waiting for the lock
       if (this->prolongation[refinement_case - 1][child].n() ==
@@ -1434,7 +1434,7 @@ FE_Q_Base<PolynomialType, dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       // if matrix got updated while waiting for the lock...
       if (this->restriction[refinement_case - 1][child].n() ==
index ee31a18fddf56bc61ad9bf659a50ce5cdcc00d3d..89f88c634fa55463f410f1f920554d02e8c29e38 100644 (file)
@@ -718,7 +718,7 @@ FESystem<dim, spacedim>::get_restriction_matrix(
   // initialization upon first request
   if (this->restriction[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       // check if updated while waiting for lock
       if (this->restriction[refinement_case - 1][child].n() ==
@@ -815,7 +815,7 @@ FESystem<dim, spacedim>::get_prolongation_matrix(
   // restriction matrix
   if (this->prolongation[refinement_case - 1][child].n() == 0)
     {
-      Threads::Mutex::ScopedLock lock(this->mutex);
+      std::lock_guard<std::mutex> lock(this->mutex);
 
       if (this->prolongation[refinement_case - 1][child].n() ==
           this->dofs_per_cell)
index a342cd06c981de6d590b00c242742ad2b1693871..5289c9d1e7ce1bc0a17758f10a57fb3bfea5be35 100644 (file)
@@ -321,7 +321,7 @@ MappingFEField<dim, spacedim, VectorType, DoFHandlerType>::get_vertices(
       euler_dof_handler->get_fe().n_components()));
 
   {
-    Threads::Mutex::ScopedLock lock(fe_values_mutex);
+    std::lock_guard<std::mutex> lock(fe_values_mutex);
     fe_values.reinit(dof_cell);
     fe_values.get_function_values(*euler_vector, values);
   }
index c95ebb6981c66815928d63d440e39fd7f7ecde9b..e4bd088f83cc364baf0c53bf14825b0c28e7db28 100644 (file)
@@ -221,7 +221,7 @@ MappingQEulerian<dim, VectorType, spacedim>::MappingQEulerianGeneric::
   // fill shift vector for each support point using an fe_values object. make
   // sure that the fe_values variable isn't used simultaneously from different
   // threads
-  Threads::Mutex::ScopedLock lock(fe_values_mutex);
+  std::lock_guard<std::mutex> lock(fe_values_mutex);
   fe_values.reinit(dof_cell);
   if (mg_vector)
     {
index a516bddb57763b1138a29cc34d24a3d6a5713e0c..e075424f7975f6b562f4bff2f6d8503dfaee485e 100644 (file)
@@ -670,7 +670,7 @@ LAPACKFullMatrix<number>::vmult(Vector<number> &      w,
         }
       case svd:
         {
-          Threads::Mutex::ScopedLock lock(mutex);
+          std::lock_guard<std::mutex> lock(mutex);
           AssertDimension(v.size(), this->n());
           AssertDimension(w.size(), this->m());
           // Compute V^T v
@@ -705,7 +705,7 @@ LAPACKFullMatrix<number>::vmult(Vector<number> &      w,
         }
       case inverse_svd:
         {
-          Threads::Mutex::ScopedLock lock(mutex);
+          std::lock_guard<std::mutex> lock(mutex);
           AssertDimension(w.size(), this->n());
           AssertDimension(v.size(), this->m());
           // Compute U^T v
@@ -805,7 +805,7 @@ LAPACKFullMatrix<number>::Tvmult(Vector<number> &      w,
         }
       case svd:
         {
-          Threads::Mutex::ScopedLock lock(mutex);
+          std::lock_guard<std::mutex> lock(mutex);
           AssertDimension(w.size(), this->n());
           AssertDimension(v.size(), this->m());
 
@@ -841,7 +841,7 @@ LAPACKFullMatrix<number>::Tvmult(Vector<number> &      w,
         }
       case inverse_svd:
         {
-          Threads::Mutex::ScopedLock lock(mutex);
+          std::lock_guard<std::mutex> lock(mutex);
           AssertDimension(v.size(), this->n());
           AssertDimension(w.size(), this->m());
 
@@ -996,7 +996,7 @@ LAPACKFullMatrix<number>::Tmmult(LAPACKFullMatrix<number> &      C,
   // https://stackoverflow.com/questions/3548069/multiplying-three-matrices-in-blas-with-the-middle-one-being-diagonal
   // http://mathforum.org/kb/message.jspa?messageID=3546564
 
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   // First, get V*B into "work" array
   work.resize(kk * nn);
   // following http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=768#p2577
@@ -1369,7 +1369,7 @@ template <typename number>
 number
 LAPACKFullMatrix<number>::norm(const char type) const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   Assert(state == LAPACKSupport::matrix ||
            state == LAPACKSupport::inverse_matrix,
@@ -1447,7 +1447,7 @@ template <typename number>
 number
 LAPACKFullMatrix<number>::reciprocal_condition_number(const number a_norm) const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   Assert(state == cholesky, ExcState(state));
   number rcond = 0.;
 
@@ -1480,7 +1480,7 @@ template <typename number>
 number
 LAPACKFullMatrix<number>::reciprocal_condition_number() const
 {
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
   Assert(property == upper_triangular || property == lower_triangular,
          ExcProperty(property));
   number rcond = 0.;
index 4923436c5369906a04c7f851c8873fc497fd6722..8067646a20bef2bf9254932b7612ff8ebd25845f 100644 (file)
@@ -1388,7 +1388,7 @@ ScaLAPACKMatrix<NumberType>::eigenpairs_symmetric(
   Assert(property == LAPACKSupport::symmetric,
          ExcMessage("Matrix has to be symmetric for this operation."));
 
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   const bool use_values = (std::isnan(eigenvalue_limits.first) ||
                            std::isnan(eigenvalue_limits.second)) ?
@@ -1719,7 +1719,7 @@ ScaLAPACKMatrix<NumberType>::eigenpairs_symmetric_MRRR(
   Assert(property == LAPACKSupport::symmetric,
          ExcMessage("Matrix has to be symmetric for this operation."));
 
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   const bool use_values = (std::isnan(eigenvalue_limits.first) ||
                            std::isnan(eigenvalue_limits.second)) ?
@@ -1956,7 +1956,7 @@ ScaLAPACKMatrix<NumberType>::compute_SVD(ScaLAPACKMatrix<NumberType> *U,
              ExcDimensionMismatch(grid->blacs_context,
                                   VT->grid->blacs_context));
     }
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   std::vector<NumberType> sv(std::min(n_rows, n_columns));
 
@@ -2071,7 +2071,7 @@ ScaLAPACKMatrix<NumberType>::least_squares(ScaLAPACKMatrix<NumberType> &B,
          ExcMessage(
            "Use identical block-cyclic distribution for matrices A and B"));
 
-  Threads::Mutex::ScopedLock lock(mutex);
+  std::lock_guard<std::mutex> lock(mutex);
 
   if (grid->mpi_process_is_active)
     {
@@ -2223,8 +2223,8 @@ ScaLAPACKMatrix<NumberType>::reciprocal_condition_number(
   Assert(state == LAPACKSupport::cholesky,
          ExcMessage(
            "Matrix has to be in Cholesky state before calling this function."));
-  Threads::Mutex::ScopedLock lock(mutex);
-  NumberType                 rcond = 0.;
+  std::lock_guard<std::mutex> lock(mutex);
+  NumberType                  rcond = 0.;
 
   if (grid->mpi_process_is_active)
     {
@@ -2326,8 +2326,8 @@ ScaLAPACKMatrix<NumberType>::norm_general(const char type) const
   Assert(state == LAPACKSupport::matrix ||
            state == LAPACKSupport::inverse_matrix,
          ExcMessage("norms can be called in matrix state only."));
-  Threads::Mutex::ScopedLock lock(mutex);
-  NumberType                 res = 0.;
+  std::lock_guard<std::mutex> lock(mutex);
+  NumberType                  res = 0.;
 
   if (grid->mpi_process_is_active)
     {
@@ -2387,8 +2387,8 @@ ScaLAPACKMatrix<NumberType>::norm_symmetric(const char type) const
          ExcMessage("norms can be called in matrix state only."));
   Assert(property == LAPACKSupport::symmetric,
          ExcMessage("Matrix has to be symmetric for this operation."));
-  Threads::Mutex::ScopedLock lock(mutex);
-  NumberType                 res = 0.;
+  std::lock_guard<std::mutex> lock(mutex);
+  NumberType                  res = 0.;
 
   if (grid->mpi_process_is_active)
     {
index 706dad4d6a8fed0c3c9844fad17c49d11560d510..a02ca2250b90f5a37ebbe4c18aa8547bee363a35 100644 (file)
@@ -50,7 +50,7 @@ execute(int i)
   // accessed
   static Threads::Mutex m;
   {
-    Threads::Mutex::ScopedLock l(m);
+    std::lock_guard<std::mutex> l(m);
     ++counter;
   }
 
index d0c6b021153e4bba4377338b5e423923c939e428..c8e15e42c79570080111fe67732ffd2be79a00e2 100644 (file)
@@ -60,7 +60,7 @@ execute(int i)
   // accessed
   static Threads::Mutex m;
   {
-    Threads::Mutex::ScopedLock l(m);
+    std::lock_guard<std::mutex> l(m);
     ++counter;
   }
 
index 530325a04b395303e4219ea59a42aa031daa454e..13ec25e21faa1b497246afa9f99a2dc7898e2f5c 100644 (file)
@@ -430,7 +430,7 @@ namespace LaplaceSolver
 
         cell->get_dof_indices(local_dof_indices);
 
-        Threads::Mutex::ScopedLock lock(mutex);
+        std::lock_guard<std::mutex> lock(mutex);
         for (unsigned int i = 0; i < dofs_per_cell; ++i)
           for (unsigned int j = 0; j < dofs_per_cell; ++j)
             linear_system.matrix.add(local_dof_indices[i],
index 4c623a28588690b7cbfb68822765d38602c762fc..e203697ea8000d5063c74b5543f6a160e767fd13 100644 (file)
@@ -512,7 +512,7 @@ namespace LaplaceSolver
 
 
         cell->get_dof_indices(local_dof_indices);
-        Threads::Mutex::ScopedLock lock(mutex);
+        std::lock_guard<std::mutex> lock(mutex);
         for (unsigned int i = 0; i < dofs_per_cell; ++i)
           for (unsigned int j = 0; j < dofs_per_cell; ++j)
             linear_system.matrix.add(local_dof_indices[i],
index d630eedaf8dc3f8d84485b12eac6cbd56005a65a..dc11a422be89dd29e877f3f93169ba3db32db7cf 100644 (file)
@@ -517,7 +517,7 @@ namespace LaplaceSolver
 
 
         cell->get_dof_indices(local_dof_indices);
-        Threads::Mutex::ScopedLock lock(mutex);
+        std::lock_guard<std::mutex> lock(mutex);
         for (unsigned int i = 0; i < dofs_per_cell; ++i)
           for (unsigned int j = 0; j < dofs_per_cell; ++j)
             linear_system.matrix.add(local_dof_indices[i],
index 1528c835ecf6e223d2652666e8157197c0d77e11..6204be258e85d0b2bb16af50fb97c0f2fad994ab 100644 (file)
@@ -429,7 +429,7 @@ namespace LaplaceSolver
 
         cell->get_dof_indices(local_dof_indices);
 
-        Threads::Mutex::ScopedLock lock(mutex);
+        std::lock_guard<std::mutex> lock(mutex);
         for (unsigned int i = 0; i < dofs_per_cell; ++i)
           for (unsigned int j = 0; j < dofs_per_cell; ++j)
             linear_system.matrix.add(local_dof_indices[i],
index 2c2903e6a4a2f29b770c9d4ee7c922825bdb76ef..e5c8f6ab8fddc89eb4c9be9db1fb7035679825cb 100644 (file)
@@ -39,8 +39,8 @@ public:
   virtual void
   end_sweep()
   {
-    static Threads::Mutex      mutex;
-    Threads::Mutex::ScopedLock lock(mutex);
+    static Threads::Mutex       mutex;
+    std::lock_guard<std::mutex> lock(mutex);
     end_sweep_flags[time_step_number] = true;
   }
 

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.