X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2a31ff2ff553129f2c0650e8984c5975748de379..c7e5d6700babea882557fae8ff23cddf01791f66:/src/simix/smx_synchro_private.h diff --git a/src/simix/smx_synchro_private.h b/src/simix/smx_synchro_private.h index 802716a13d..943e1adf1c 100644 --- a/src/simix/smx_synchro_private.h +++ b/src/simix/smx_synchro_private.h @@ -36,13 +36,15 @@ public: // boost::intrusive_ptr support: friend void intrusive_ptr_add_ref(Mutex* mutex) { - auto previous = ++mutex->refcount_; + // 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) { - auto count = mutex->refcount_--; + // Atomic operation! Do not split in two instructions! + auto count = --(mutex->refcount_); if (count == 0) delete mutex; } @@ -56,6 +58,7 @@ private: typedef struct s_smx_cond { smx_mutex_t mutex; xbt_swag_t sleeping; /* list of sleeping process */ + std::atomic_int_fast32_t refcount_; } s_smx_cond_t; typedef struct s_smx_sem { @@ -77,4 +80,6 @@ XBT_PRIVATE void SIMIX_sem_release(smx_sem_t sem); XBT_PRIVATE int SIMIX_sem_would_block(smx_sem_t sem); XBT_PRIVATE int SIMIX_sem_get_capacity(smx_sem_t sem); +XBT_PRIVATE void intrusive_ptr_release(s_smx_cond_t *cond); +XBT_PRIVATE void intrusive_ptr_add_ref(s_smx_cond_t *cond); #endif