From: Arnaud Giersch Date: Thu, 3 May 2018 12:02:01 +0000 (+0200) Subject: Modernize simcall process_on_exit. X-Git-Tag: v3.20~298 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d60c93c4ec0ba158a9e58681f4df021f76e78f9e?hp=28cf1594ef109bb3cd215fd9b0f16a5418ca999e Modernize simcall process_on_exit. --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 7c50946ca1..1a2c48a722 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -197,7 +197,6 @@ XBT_PUBLIC void simcall_process_suspend(smx_actor_t process); /* Getters and Setters */ XBT_PUBLIC void simcall_process_set_data(smx_actor_t process, void* data); XBT_PUBLIC void simcall_process_set_kill_time(smx_actor_t process, double kill_time); -XBT_PUBLIC void simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data); XBT_PUBLIC void simcall_process_join(smx_actor_t process, double timeout); /* Sleep control */ XBT_PUBLIC e_smx_state_t simcall_process_sleep(double duration); diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index fd37ef49ed..c2cdf20b0b 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -154,7 +154,7 @@ msg_process_t MSG_process_create_from_stdfunc(const char* name, std::functionciface()->on_exit((int_f_pvoid_pvoid_t)TRACE_msg_process_kill, process); return process->ciface(); } @@ -181,7 +181,7 @@ msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, SIMIX_process_attach(name, new simgrid::msg::ActorExt(data), host->get_cname(), &props, nullptr); if (not process) xbt_die("Could not attach"); - simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process); + process->ciface()->on_exit((int_f_pvoid_pvoid_t)TRACE_msg_process_kill, process); return process->ciface(); } @@ -320,7 +320,7 @@ smx_context_t MSG_process_get_smx_ctx(msg_process_t process) { // deprecated -- * You should use them to free the data used by your process. */ void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data) { - simcall_process_on_exit(SIMIX_process_self(), fun, data); + simgrid::s4u::this_actor::on_exit(fun, data); } /** * \ingroup m_process_management diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 2228a91273..d5e30664ee 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -69,7 +69,7 @@ void Actor::set_auto_restart(bool autorestart) void Actor::on_exit(int_f_pvoid_pvoid_t fun, void* data) { - simcall_process_on_exit(pimpl_, fun, data); + simgrid::simix::kernelImmediate([&] { SIMIX_process_on_exit(pimpl_, fun, data); }); } /** @brief Moves the actor to another host @@ -385,7 +385,7 @@ void kill() void on_exit(int_f_pvoid_pvoid_t fun, void* data) { - simcall_process_on_exit(SIMIX_process_self(), fun, data); + SIMIX_process_self()->iface()->on_exit(fun, data); } /** @brief Moves the current actor to another host diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index d685e4bce3..4f28081527 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -225,16 +225,6 @@ void simcall_process_set_kill_time(smx_actor_t process, double kill_time) }); } -/** - * \ingroup simix_process_management - * \brief Add an on_exit function - * Add an on_exit function which will be executed when the process exits/is killed. - */ -XBT_PUBLIC void simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data) -{ - simcall_BODY_process_on_exit(process, fun, data); -} - /** * \ingroup simix_process_management * \brief Creates a new sleep SIMIX synchro. diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 5d8c7d1ae1..3a0db683bf 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -313,43 +313,6 @@ static inline void simcall_execution_test__set__result(smx_simcall_t simcall, in simgrid::simix::marshal(simcall->result, result); } -static inline smx_actor_t simcall_process_on_exit__get__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_actor_t simcall_process_on_exit__getraw__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_process_on_exit__set__process(smx_simcall_t simcall, smx_actor_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline int_f_pvoid_pvoid_t simcall_process_on_exit__get__fun(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline int_f_pvoid_pvoid_t simcall_process_on_exit__getraw__fun(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_process_on_exit__set__fun(smx_simcall_t simcall, int_f_pvoid_pvoid_t arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} -static inline void* simcall_process_on_exit__get__data(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[2]); -} -static inline void* simcall_process_on_exit__getraw__data(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[2]); -} -static inline void simcall_process_on_exit__set__data(smx_simcall_t simcall, void* arg) -{ - simgrid::simix::marshal(simcall->args[2], arg); -} - static inline smx_mailbox_t simcall_comm_iprobe__get__mbox(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index c0f8318125..15fed6871c 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -88,13 +88,6 @@ inline static int simcall_BODY_execution_test(boost::intrusive_ptr>(SIMCALL_EXECUTION_TEST, execution); } -inline static void simcall_BODY_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data) -{ - if (0) /* Go to that function to follow the code flow through the simcall barrier */ - SIMIX_process_on_exit(process, fun, data); - return simcall(SIMCALL_PROCESS_ON_EXIT, process, fun, data); -} - inline static boost::intrusive_ptr simcall_BODY_comm_iprobe(smx_mailbox_t mbox, int type, simix_match_func_t match_fun, void* data) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 2c83ae22bd..fa3e71d248 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -26,7 +26,6 @@ typedef enum { SIMCALL_EXECUTION_PARALLEL_START, SIMCALL_EXECUTION_WAIT, SIMCALL_EXECUTION_TEST, - SIMCALL_PROCESS_ON_EXIT, SIMCALL_COMM_IPROBE, SIMCALL_COMM_SEND, SIMCALL_COMM_ISEND, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index d4502d96b8..ea1765ceda 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -35,7 +35,6 @@ const char* simcall_names[] = { "SIMCALL_EXECUTION_PARALLEL_START", "SIMCALL_EXECUTION_WAIT", "SIMCALL_EXECUTION_TEST", - "SIMCALL_PROCESS_ON_EXIT", "SIMCALL_COMM_IPROBE", "SIMCALL_COMM_SEND", "SIMCALL_COMM_ISEND", @@ -109,11 +108,6 @@ case SIMCALL_EXECUTION_TEST: simgrid::simix::unmarshal>(simcall->args[0])); break; -case SIMCALL_PROCESS_ON_EXIT: - SIMIX_process_on_exit(simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2])); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_COMM_IPROBE: simgrid::simix::marshal>(simcall->result, simcall_HANDLER_comm_iprobe(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2]), simgrid::simix::unmarshal(simcall->args[3]))); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 08017327a1..c72d961563 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -44,8 +44,6 @@ boost::intrusive_ptr execution_parallel_sta int execution_wait(boost::intrusive_ptr execution) [[block]]; int execution_test(boost::intrusive_ptr execution) [[block]]; -void process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data) [[nohandler]]; - boost::intrusive_ptr comm_iprobe(smx_mailbox_t mbox, int type, simix_match_func_t match_fun, void* data); void comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) [[block]]; boost::intrusive_ptr comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);