+
+ // boost::intrusive_ptr<Mutex> support:
+ friend void intrusive_ptr_add_ref(Mutex* mutex)
+ {
+ // Atomic operation! Do not split in two instructions!
+ auto previous = (mutex->refcount_)++;
+ xbt_assert(previous != 0);
+ (void) previous;
+ }
+ friend void intrusive_ptr_release(Mutex* mutex)
+ {
+ // Atomic operation! Do not split in two instructions!
+ auto count = --(mutex->refcount_);
+ if (count == 0)
+ delete mutex;
+ }
+
+ simgrid::s4u::Mutex& mutex() { return mutex_; }
+
+private:
+ std::atomic_int_fast32_t refcount_ { 1 };
+ simgrid::s4u::Mutex mutex_;