X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d656f9465e7b1c36319f86eeafdcec58fe9551a4..77bbf3027c4240a2e833209a3a3f186589da8577:/src/simix/smx_synchro_private.hpp diff --git a/src/simix/smx_synchro_private.hpp b/src/simix/smx_synchro_private.hpp index 734998207d..5846b045f1 100644 --- a/src/simix/smx_synchro_private.hpp +++ b/src/simix/smx_synchro_private.hpp @@ -31,15 +31,12 @@ public: // boost::intrusive_ptr support: friend void intrusive_ptr_add_ref(MutexImpl* mutex) { - // Atomic operation! Do not split in two instructions! - XBT_ATTRIB_UNUSED auto previous = (mutex->refcount_)++; + XBT_ATTRIB_UNUSED auto previous = mutex->refcount_.fetch_add(1); xbt_assert(previous != 0); } friend void intrusive_ptr_release(MutexImpl* mutex) { - // Atomic operation! Do not split in two instructions! - auto count = --(mutex->refcount_); - if (count == 0) + if (mutex->refcount_.fetch_sub(1) == 1) delete mutex; }