Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar
[simgrid.git] / src / kernel / activity / ActivityImpl.hpp
index 94b8590..e144296 100644 (file)
@@ -12,6 +12,7 @@
 #include <xbt/base.h>
 #include "simgrid/forward.h"
 
+#include <atomic>
 #include <simgrid/simix.hpp>
 
 namespace simgrid {
@@ -30,10 +31,24 @@ namespace activity {
     virtual void resume()=0;
     virtual void post() =0; // What to do when a simcall terminates
 
+    // boost::intrusive_ptr<Activity> support:
+    friend void intrusive_ptr_add_ref(ActivityImpl * activity)
+    {
+      activity->ref();
+    }
+
+    friend void intrusive_ptr_release(ActivityImpl * activity)
+    {
+      activity->unref();
+    }
+
+    /** @brief Increases the refcount */
     void ref();
+    /** @brief Reduces the refcount */
     void unref();
+
   private:
-    int refcount = 1;
+    std::atomic_int_fast32_t refcount_{1};
   };
 }}} // namespace simgrid::kernel::activity