+ Mutex() :
+ mutex_(simcall_mutex_init()) {}
+ Mutex(simgrid::simix::Mutex* mutex) : mutex_(SIMIX_mutex_dup(mutex)) {}
+ ~Mutex()
+ {
+ SIMIX_mutex_destroy(mutex_);
+ }
+
+ // Copy+move (with the copy-and-swap idiom):
+ Mutex(Mutex const& mutex) : mutex_(SIMIX_mutex_dup(mutex.mutex_)) {}
+ friend void swap(Mutex& first, Mutex& second)
+ {
+ using std::swap;
+ swap(first.mutex_, second.mutex_);
+ }
+ Mutex& operator=(Mutex mutex)
+ {
+ swap(*this, mutex);
+ return *this;
+ }
+ Mutex(Mutex&& mutex) : mutex_(nullptr)
+ {
+ swap(*this, mutex);
+ }
+
+ bool valid() const
+ {
+ return mutex_ != nullptr;
+ }