Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'condvar'
[simgrid.git] / include / simgrid / s4u / mutex.hpp
index da7c3df..75b7d09 100644 (file)
 #include <boost/intrusive_ptr.hpp>
 #include <xbt/base.h>
 #include "simgrid/simix.h"
+#include <simgrid/s4u/conditionVariable.hpp>
 
 namespace simgrid {
 namespace s4u {
 
+class ConditionVariable;
 XBT_PUBLIC_CLASS Mutex {
-
+friend ConditionVariable;
 public:
   Mutex() :
     mutex_(simcall_mutex_init()) {}
-  Mutex(simgrid::simix::Mutex* mutex) : mutex_(SIMIX_mutex_dup(mutex)) {}
+  Mutex(simgrid::simix::Mutex* mutex) : mutex_(SIMIX_mutex_ref(mutex)) {}
   ~Mutex()
   {
-    SIMIX_mutex_destroy(mutex_);
+    SIMIX_mutex_unref(mutex_);
   }
 
   // Copy+move (with the copy-and-swap idiom):
-  Mutex(Mutex const& mutex) : mutex_(SIMIX_mutex_dup(mutex.mutex_)) {}
+  Mutex(Mutex const& mutex) : mutex_(SIMIX_mutex_ref(mutex.mutex_)) {}
   friend void swap(Mutex& first, Mutex& second)
   {
     using std::swap;