X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/eb1ee003aa8db4bbfcc49860f6cac03771897500..cb6448e71a64791c262d6c40c050cc0b8d8ed184:/include/simgrid/s4u/mutex.hpp diff --git a/include/simgrid/s4u/mutex.hpp b/include/simgrid/s4u/mutex.hpp index da7c3df863..ff60143540 100644 --- a/include/simgrid/s4u/mutex.hpp +++ b/include/simgrid/s4u/mutex.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_S4U_MUTEX_HPP #define SIMGRID_S4U_MUTEX_HPP +#include #include #include @@ -15,19 +16,21 @@ namespace simgrid { namespace s4u { -XBT_PUBLIC_CLASS Mutex { +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; @@ -56,6 +59,7 @@ public: private: simgrid::simix::Mutex* mutex_; }; + }} // namespace simgrid::s4u #endif /* SIMGRID_S4U_MUTEX_HPP */