Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Restore handling of msg_global->process_data_cleanup.
[simgrid.git] / src / msg / msg_global.cpp
index e061e0c..d8e0f77 100644 (file)
@@ -17,7 +17,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kerne
 bool MSG_Global_t::debug_multiple_use = false;
 
 MSG_Global_t* msg_global = nullptr;
-simgrid::xbt::Extension<simgrid::s4u::Actor, simgrid::msg::ActorUserData> simgrid::msg::ActorUserData::EXTENSION_ID;
 
 static void MSG_exit();
 
@@ -43,7 +42,12 @@ void MSG_init_nocheck(int *argc, char **argv) {
     msg_global->sent_msg = 0;
     msg_global->task_copy_callback = nullptr;
     msg_global->process_data_cleanup = nullptr;
-    MSG_process_userdata_init();
+    simgrid::s4u::Actor::on_termination.connect([](simgrid::s4u::Actor const& actor) {
+      // free the data if a function was provided
+      void* userdata = sg_actor_data(&actor);
+      if (userdata && msg_global->process_data_cleanup)
+        msg_global->process_data_cleanup(userdata);
+    });
   }
 
   if(MC_is_active()){