Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
these archaic callbacks are not used anymore, so kill them
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 4 Nov 2018 04:33:09 +0000 (05:33 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 4 Nov 2018 04:33:09 +0000 (05:33 +0100)
include/simgrid/simix.h
include/simgrid/simix.hpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp
src/simix/smx_global.cpp
src/simix/smx_private.hpp
src/surf/HostImpl.cpp
src/surf/sg_platf.cpp

index 18451af..2a15302 100644 (file)
@@ -93,9 +93,6 @@ XBT_PUBLIC void SIMIX_global_init(int* argc, char** argv);
  * is assumed to be the maestro. */
 XBT_PUBLIC void SIMIX_set_maestro(void (*code)(void*), void* data);
 
-XBT_PUBLIC void SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function);
-XBT_PUBLIC void SIMIX_function_register_process_kill(void_pfn_smxprocess_t function);
-
 /* Simulation execution */
 XBT_PUBLIC void SIMIX_run();
 XBT_PUBLIC double SIMIX_get_clock();
index 9720dc8..341f54f 100644 (file)
@@ -95,8 +95,6 @@ typedef smx_actor_t (*smx_creation_func_t)(
     /* props */ std::unordered_map<std::string, std::string>*,
     /* parent_process */ smx_actor_t);
 
-XBT_PUBLIC void SIMIX_function_register_process_create(smx_creation_func_t function);
-
 XBT_PUBLIC smx_actor_t simcall_process_create(std::string name, simgrid::simix::ActorCode code, void* data,
                                               sg_host_t host, std::unordered_map<std::string, std::string>* properties);
 
index 5842df4..88734d6 100644 (file)
@@ -178,8 +178,8 @@ simgrid::s4u::Actor* ActorImpl::restart()
   SIMIX_process_kill(this, (this == simix_global->maestro_process) ? this : SIMIX_process_self());
 
   // start the new process
-  ActorImpl* actor = simix_global->create_process_function(arg.name.c_str(), std::move(arg.code), arg.data, arg.host,
-                                                           arg.properties.get(), nullptr);
+  ActorImpl* actor =
+      SIMIX_process_create(arg.name.c_str(), std::move(arg.code), arg.data, arg.host, arg.properties.get(), nullptr);
   simcall_process_set_kill_time(actor, arg.kill_time);
   actor->set_auto_restart(arg.auto_restart);
 
@@ -359,7 +359,7 @@ smx_actor_t SIMIX_process_create(std::string name, simgrid::simix::ActorCode cod
   process->code         = code;
 
   XBT_VERB("Create context %s", process->get_cname());
-  process->context_ = SIMIX_context_new(std::move(code), simix_global->cleanup_process_function, process);
+  process->context_ = SIMIX_context_new(std::move(code), &SIMIX_process_cleanup, process);
 
   /* Add properties */
   if (properties != nullptr)
@@ -416,7 +416,7 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn
   XBT_VERB("Create context %s", process->get_cname());
   if (not simix_global)
     xbt_die("simix is not initialized, please call MSG_init first");
-  process->context_ = simix_global->context_factory->attach(simix_global->cleanup_process_function, process);
+  process->context_ = simix_global->context_factory->attach(&SIMIX_process_cleanup, process);
 
   /* Add properties */
   if (properties != nullptr)
@@ -452,7 +452,7 @@ void SIMIX_process_detach()
     xbt_die("Not a suitable context");
 
   auto process = context->process();
-  simix_global->cleanup_process_function(process);
+  SIMIX_process_cleanup(process);
   context->attach_stop();
 }
 
index cff0c83..850f15d 100644 (file)
@@ -198,11 +198,11 @@ void simcall_process_set_data(smx_actor_t process, void *data)
 void simcall_process_set_kill_time(smx_actor_t process, double kill_time)
 {
 
-  if (kill_time <= SIMIX_get_clock() || simix_global->kill_process_function == nullptr)
+  if (kill_time <= SIMIX_get_clock())
     return;
   XBT_DEBUG("Set kill time %f for process %s@%s", kill_time, process->get_cname(), process->host_->get_cname());
   process->kill_timer = SIMIX_timer_set(kill_time, [process] {
-    simix_global->kill_process_function(process);
+    SIMIX_process_kill(process, nullptr);
     process->kill_timer=nullptr;
   });
 }
index d61721f..724b157 100644 (file)
@@ -182,9 +182,6 @@ void SIMIX_global_init(int *argc, char **argv)
   if (not simix_global) {
     simix_global = std::unique_ptr<simgrid::simix::Global>(new simgrid::simix::Global());
     simix_global->maestro_process = nullptr;
-    simix_global->create_process_function = &SIMIX_process_create;
-    simix_global->kill_process_function = &kill_process;
-    simix_global->cleanup_process_function = &SIMIX_process_cleanup;
 
     surf_init(argc, argv);      /* Initialize SURF structures */
     SIMIX_context_mod_init();
@@ -560,45 +557,6 @@ double SIMIX_timer_get_date(smx_timer_t timer) {
   return timer ? timer->getDate() : 0;
 }
 
-/**
- * @brief Registers a function to create a process.
- *
- * This function registers a function to be called
- * when a new process is created. The function has
- * to call SIMIX_process_create().
- * @param function create process function
- */
-void SIMIX_function_register_process_create(smx_creation_func_t function)
-{
-  simix_global->create_process_function = function;
-}
-
-/**
- * @brief Registers a function to kill a process.
- *
- * This function registers a function to be called when a process is killed. The function has to call the
- * SIMIX_process_kill().
- *
- * @param function Kill process function
- */
-void SIMIX_function_register_process_kill(void_pfn_smxprocess_t function)
-{
-  simix_global->kill_process_function = function;
-}
-
-/**
- * @brief Registers a function to cleanup a process.
- *
- * This function registers a user function to be called when a process ends properly.
- *
- * @param function cleanup process function
- */
-void SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function)
-{
-  simix_global->cleanup_process_function = function;
-}
-
-
 void SIMIX_display_process_status()
 {
   int nbprocess = simix_global->process_list.size();
index ea586f1..830a2f8 100644 (file)
@@ -53,10 +53,6 @@ public:
   // This might be used when no corresponding function name is registered:
   simgrid::simix::ActorCodeFactory default_function;
 
-  smx_creation_func_t create_process_function = nullptr;
-  void_pfn_smxprocess_t kill_process_function = nullptr;
-  /** Callback used when killing a SMX_process */
-  void_pfn_smxprocess_t cleanup_process_function = nullptr;
   std::mutex mutex;
 
   std::vector<simgrid::xbt::Task<void()>> tasks;
index ce622c4..32e7c03 100644 (file)
@@ -124,8 +124,8 @@ void HostImpl::turn_on()
 {
   for (auto const& arg : actors_at_boot_) {
     XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
-    smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host,
-                                                              arg->properties.get(), nullptr);
+    smx_actor_t actor =
+        SIMIX_process_create(arg->name.c_str(), arg->code, nullptr, arg->host, arg->properties.get(), nullptr);
     if (arg->kill_time >= 0)
       simcall_process_set_kill_time(actor, arg->kill_time);
     if (arg->auto_restart)
index e3e5253..aaf5bfa 100644 (file)
@@ -452,8 +452,8 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
 
     XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time);
     SIMIX_timer_set(start_time, [arg, auto_restart]() {
-      smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), std::move(arg->code), arg->data,
-                                                                arg->host, arg->properties.get(), nullptr);
+      smx_actor_t actor = SIMIX_process_create(arg->name.c_str(), std::move(arg->code), arg->data, arg->host,
+                                               arg->properties.get(), nullptr);
       if (arg->kill_time >= 0)
         simcall_process_set_kill_time(actor, arg->kill_time);
       if (auto_restart)
@@ -463,8 +463,8 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
   } else {                      // start_time <= SIMIX_get_clock()
     XBT_DEBUG("Starting Process %s(%s) right now", arg->name.c_str(), host->get_cname());
 
-    smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), std::move(code), nullptr, host,
-                                                              arg->properties.get(), nullptr);
+    smx_actor_t actor =
+        SIMIX_process_create(arg->name.c_str(), std::move(code), nullptr, host, arg->properties.get(), nullptr);
 
     /* The actor creation will fail if the host is currently dead, but that's fine */
     if (actor != nullptr) {