From 6126924e83eded994bef252b90becedc31015a59 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 4 Nov 2018 05:33:09 +0100 Subject: [PATCH] these archaic callbacks are not used anymore, so kill them --- include/simgrid/simix.h | 3 --- include/simgrid/simix.hpp | 2 -- src/simix/ActorImpl.cpp | 10 +++++----- src/simix/libsmx.cpp | 4 ++-- src/simix/smx_global.cpp | 42 --------------------------------------- src/simix/smx_private.hpp | 4 ---- src/surf/HostImpl.cpp | 4 ++-- src/surf/sg_platf.cpp | 8 ++++---- 8 files changed, 13 insertions(+), 64 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 18451af516..2a15302791 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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(); diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 9720dc87c4..341f54fbca 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -95,8 +95,6 @@ typedef smx_actor_t (*smx_creation_func_t)( /* props */ std::unordered_map*, /* 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* properties); diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 5842df4dff..88734d6cb9 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -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(); } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index cff0c834e2..850f15defc 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -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; }); } diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index d61721f99a..724b15754a 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -182,9 +182,6 @@ void SIMIX_global_init(int *argc, char **argv) if (not simix_global) { simix_global = std::unique_ptr(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(); diff --git a/src/simix/smx_private.hpp b/src/simix/smx_private.hpp index ea586f129a..830a2f819d 100644 --- a/src/simix/smx_private.hpp +++ b/src/simix/smx_private.hpp @@ -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> tasks; diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index ce622c4bf2..32e7c03c44 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -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) diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index e3e5253eab..aaf5bfa517 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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) { -- 2.20.1