getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r4810 - in /trunk/getfem/src: getfem/getfem_omp.h getfe


From: andriy . andreykiv
Subject: [Getfem-commits] r4810 - in /trunk/getfem/src: getfem/getfem_omp.h getfem_omp.cc
Date: Tue, 11 Nov 2014 13:16:21 -0000

Author: andrico
Date: Tue Nov 11 14:16:21 2014
New Revision: 4810

URL: http://svn.gna.org/viewcvs/getfem?rev=4810&view=rev
Log:
replacing boost::mutex with boost::recursive_mutex 
to prevent a thread locking itself

Modified:
    trunk/getfem/src/getfem/getfem_omp.h
    trunk/getfem/src/getfem_omp.cc

Modified: trunk/getfem/src/getfem/getfem_omp.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_omp.h?rev=4810&r1=4809&r2=4810&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_omp.h        (original)
+++ trunk/getfem/src/getfem/getfem_omp.h        Tue Nov 11 14:16:21 2014
@@ -72,24 +72,24 @@
 #ifdef GETFEM_HAVE_OPENMP
   //declaring a thread lock, to protect multi-threaded accesses to
   //asserts, traces and warnings. Using a global mutex
-  class omp_guard: public boost::lock_guard<boost::mutex>
+  class omp_guard: public boost::lock_guard<boost::recursive_mutex>
   {
   public:
     omp_guard();
   private:
-    static boost::mutex boost_mutex;
+    static boost::recursive_mutex boost_mutex;
   };
 
   //like boost::lock_guard, but copyable
   class local_guard 
   {
   public:
-    local_guard(boost::mutex&);
+    local_guard(boost::recursive_mutex&);
     local_guard(const local_guard&);
 
   private:
-    boost::mutex& mutex_;
-    boost::shared_ptr<boost::lock_guard<boost::mutex>> plock_;
+    boost::recursive_mutex& mutex_;
+    boost::shared_ptr<boost::lock_guard<boost::recursive_mutex>> plock_;
   };
 
   //produces scoped lock on the 
@@ -103,7 +103,7 @@
     //on the mutex from this factory
     local_guard get_lock() const;
   private:
-    mutable boost::mutex mutex_;
+    mutable boost::recursive_mutex mutex_;
   };
 
 

Modified: trunk/getfem/src/getfem_omp.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_omp.cc?rev=4810&r1=4809&r2=4810&view=diff
==============================================================================
--- trunk/getfem/src/getfem_omp.cc      (original)
+++ trunk/getfem/src/getfem_omp.cc      Tue Nov 11 14:16:21 2014
@@ -5,15 +5,15 @@
 
 #ifdef GETFEM_HAVE_OPENMP
 
-  boost::mutex omp_guard::boost_mutex;
+  boost::recursive_mutex omp_guard::boost_mutex;
 
   omp_guard::omp_guard() 
-    : boost::lock_guard<boost::mutex>(boost_mutex) 
+    : boost::lock_guard<boost::recursive_mutex>(boost_mutex) 
   {}
 
-  local_guard::local_guard(boost::mutex& m) : 
+  local_guard::local_guard(boost::recursive_mutex& m) : 
     mutex_(m), 
-    plock_(new boost::lock_guard<boost::mutex>(m))
+    plock_(new boost::lock_guard<boost::recursive_mutex>(m))
   { }
 
   local_guard::local_guard(const local_guard& guard) 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]