X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6e3289e56fd7ab16327569a2f961006bd985c2f4..4e3a5dfcf8e95dedcf2c6db54f782eccfd5554d9:/src/simix/ActorImpl.hpp diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index 3e0f707c0a..9b7e47bad6 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -14,7 +14,8 @@ typedef struct s_smx_process_exit_fun { int_f_pvoid_pvoid_t fun; void *arg; -} s_smx_process_exit_fun_t, *smx_process_exit_fun_t; +} s_smx_process_exit_fun_t; +typedef s_smx_process_exit_fun_t* smx_process_exit_fun_t; namespace simgrid { namespace simix { @@ -73,13 +74,17 @@ private: public: friend void intrusive_ptr_add_ref(ActorImpl* process) { - process->refcount_.fetch_add(1, std::memory_order_relaxed); + // std::memory_order_relaxed ought to be enough here instead of std::memory_order_seq_cst + // But then, we have a threading issue when an actor commits a suicide: + // it seems that in this case, the worker thread kills the last occurrence of the actor + // while usually, the maestro does so. FIXME: we should change how actors suicide + process->refcount_.fetch_add(1, std::memory_order_seq_cst); } friend void intrusive_ptr_release(ActorImpl* process) { // 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 + // Make sure that any changes done on other threads before their acquire are committed 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;