Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
first step towards a CommPtr
[simgrid.git] / src / kernel / activity / SynchroComm.cpp
index 1949b21..9cb4c37 100644 (file)
@@ -16,7 +16,7 @@ simgrid::kernel::activity::Comm::Comm(e_smx_comm_type_t _type) : type(_type)
   state = SIMIX_WAITING;
   src_data=nullptr;
   dst_data=nullptr;
-
+  intrusive_ptr_add_ref(this);
   XBT_DEBUG("Create communicate synchro %p", this);
 }
 
@@ -37,6 +37,7 @@ simgrid::kernel::activity::Comm::~Comm()
   if(mbox)
     mbox->remove(this);
 }
+
 void simgrid::kernel::activity::Comm::suspend()
 {
   /* FIXME: shall we suspend also the timeout synchro? */
@@ -61,6 +62,7 @@ void simgrid::kernel::activity::Comm::cancel()
   if (state == SIMIX_WAITING) {
     mbox->remove(this);
     state = SIMIX_CANCELED;
+    SIMIX_comm_unref(this);
   } else if (not MC_is_active() /* when running the MC there are no surf actions */
              && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
 
@@ -120,6 +122,8 @@ void simgrid::kernel::activity::Comm::post()
   cleanupSurf();
 
   /* if there are simcalls associated with the synchro, then answer them */
-  if (not simcalls.empty())
+  if (not simcalls.empty()) {
     SIMIX_comm_finish(this);
+    SIMIX_comm_unref(this);
+  }
 }