Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify MSG process creation/destruction
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 4 Nov 2018 04:04:55 +0000 (05:04 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 4 Nov 2018 04:05:15 +0000 (05:05 +0100)
Use a proper callback to cleanup things, and somehow, we don't need
anything special anymore when creating a MSG process, so stop making
things complicated for no reason.

src/msg/msg_global.cpp
src/msg/msg_private.hpp
src/msg/msg_process.cpp

index 22dfa7c..d6cb7f8 100644 (file)
@@ -3,12 +3,12 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "mc/mc.h"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
-
-#include "mc/mc.h"
 #include "src/instr/instr_private.hpp"
 #include "src/msg/msg_private.hpp"
 #include "src/instr/instr_private.hpp"
 #include "src/msg/msg_private.hpp"
+#include "src/simix/smx_private.hpp"
 #include <xbt/config.hpp>
 
 XBT_LOG_NEW_CATEGORY(msg, "All MSG categories");
 #include <xbt/config.hpp>
 
 XBT_LOG_NEW_CATEGORY(msg, "All MSG categories");
@@ -42,8 +42,13 @@ void MSG_init_nocheck(int *argc, char **argv) {
     msg_global->task_copy_callback = nullptr;
     msg_global->process_data_cleanup = nullptr;
 
     msg_global->task_copy_callback = nullptr;
     msg_global->process_data_cleanup = nullptr;
 
-    SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
-    SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
+    simgrid::s4u::Actor::on_destruction.connect([](simgrid::s4u::ActorPtr actor) {
+      // free the data if a function was provided
+      void* userdata = actor->get_impl()->get_user_data();
+      if (userdata && msg_global->process_data_cleanup) {
+        msg_global->process_data_cleanup(userdata);
+      }
+    });
   }
 
   if(MC_is_active()){
   }
 
   if(MC_is_active()){
index d65129c..e572623 100644 (file)
@@ -78,11 +78,6 @@ typedef s_MSG_Global_t* MSG_Global_t;
 XBT_PUBLIC_DATA MSG_Global_t msg_global;
 
 /*************************************************************/
 XBT_PUBLIC_DATA MSG_Global_t msg_global;
 
 /*************************************************************/
-XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
-XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(std::string name, simgrid::simix::ActorCode code, void* data,
-                                                      sg_host_t host,
-                                                      std::unordered_map<std::string, std::string>* properties,
-                                                      smx_actor_t parent_process);
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
 
 /********** Tracing **********/
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
 
 /********** Tracing **********/
index e7c6961..7f00a85 100644 (file)
@@ -17,29 +17,6 @@ std::string instr_pid(msg_process_t proc)
 }
 
 /******************************** Process ************************************/
 }
 
 /******************************** Process ************************************/
-/**
- * @brief Cleans the MSG data of an actor
- * @param smx_actor a SIMIX actor
- */
-void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_actor)
-{
-  // free the data if a function was provided
-  void* userdata = smx_actor->get_user_data();
-  if (userdata && msg_global->process_data_cleanup) {
-    msg_global->process_data_cleanup(userdata);
-  }
-
-  SIMIX_process_cleanup(smx_actor);
-}
-
-/* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
-smx_actor_t MSG_process_create_from_SIMIX(std::string name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
-                                          std::unordered_map<std::string, std::string>* properties,
-                                          smx_actor_t /*parent_process*/)
-{
-  msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
-  return p == nullptr ? nullptr : p->get_impl();
-}
 
 /** @brief Creates and runs a new #msg_process_t.
  *
 
 /** @brief Creates and runs a new #msg_process_t.
  *