Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
comment++ on that code that I barely understand but exhibits bugs
[simgrid.git] / src / simix / ActorImpl.hpp
index f2a18a6240b86ec0280828eb33cdf1a53a1de47e..3e0f707c0a9ddb39fb78e62ad3ad1cb6805c9366 100644 (file)
@@ -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;
     }