From 6e3289e56fd7ab16327569a2f961006bd985c2f4 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 26 Apr 2017 13:56:10 +0200 Subject: [PATCH] comment++ on that code that I barely understand but exhibits bugs --- src/simix/ActorImpl.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index f2a18a6240..3e0f707c0a 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -79,6 +79,8 @@ public: { // inspired from http://www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html if (process->refcount_.fetch_sub(1, std::memory_order_release) == 1) { + // Make sure that any changes done on other threads before their acquire are commited before our delete + // http://stackoverflow.com/questions/27751025/why-is-an-acquire-barrier-needed-before-deleting-the-data-in-an-atomically-refer std::atomic_thread_fence(std::memory_order_acquire); delete process; } -- 2.20.1