From: Martin Quinson Date: Tue, 20 Jun 2017 20:49:20 +0000 (+0200) Subject: woops, fix the refcounting of activityImpl X-Git-Tag: v3.16~18 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d51aee2857313a5120df8065a396ae4cf018d9d6 woops, fix the refcounting of activityImpl --- diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index 43ed70fb2d..0a6880363e 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -15,13 +15,15 @@ ActivityImpl::~ActivityImpl() = default; // boost::intrusive_ptr support: void intrusive_ptr_add_ref(simgrid::kernel::activity::ActivityImpl* activity) { - activity->refcount_++; + activity->refcount_.fetch_add(1, std::memory_order_relaxed); } void intrusive_ptr_release(simgrid::kernel::activity::ActivityImpl* activity) { - if (activity->refcount_-- == 0) + if (activity->refcount_.fetch_sub(1, std::memory_order_release) == 1) { + std::atomic_thread_fence(std::memory_order_acquire); delete activity; + } } } }