Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Modernize simcall process_on_exit.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 3 May 2018 12:02:01 +0000 (14:02 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 3 May 2018 12:44:15 +0000 (14:44 +0200)
include/simgrid/simix.h
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.hpp
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in

index 7c50946..1a2c48a 100644 (file)
@@ -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);
index fd37ef4..c2cdf20 100644 (file)
@@ -154,7 +154,7 @@ msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<vo
     return nullptr;
   }
 
-  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();
 }
 
@@ -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
index 2228a91..d5e3066 100644 (file)
@@ -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
index d685e4b..4f28081 100644 (file)
@@ -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.
index 5d8c7d1..3a0db68 100644 (file)
@@ -313,43 +313,6 @@ static inline void simcall_execution_test__set__result(smx_simcall_t simcall, in
   simgrid::simix::marshal<int>(simcall->result, result);
 }
 
-static inline smx_actor_t simcall_process_on_exit__get__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
-}
-static inline smx_actor_t simcall_process_on_exit__getraw__process(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<smx_actor_t>(simcall->args[0]);
-}
-static inline void simcall_process_on_exit__set__process(smx_simcall_t simcall, smx_actor_t arg)
-{
-  simgrid::simix::marshal<smx_actor_t>(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<int_f_pvoid_pvoid_t>(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<int_f_pvoid_pvoid_t>(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<int_f_pvoid_pvoid_t>(simcall->args[1], arg);
-}
-static inline void* simcall_process_on_exit__get__data(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<void*>(simcall->args[2]);
-}
-static inline void* simcall_process_on_exit__getraw__data(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<void*>(simcall->args[2]);
-}
-static inline void simcall_process_on_exit__set__data(smx_simcall_t simcall, void* arg)
-{
-  simgrid::simix::marshal<void*>(simcall->args[2], arg);
-}
-
 static inline smx_mailbox_t simcall_comm_iprobe__get__mbox(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]);
index c0f8318..15fed68 100644 (file)
@@ -88,13 +88,6 @@ inline static int simcall_BODY_execution_test(boost::intrusive_ptr<simgrid::kern
   return simcall<int, boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(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<void, smx_actor_t, int_f_pvoid_pvoid_t, void*>(SIMCALL_PROCESS_ON_EXIT, process, fun, data);
-}
-
 inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> 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 */
index 2c83ae2..fa3e71d 100644 (file)
@@ -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,
index d4502d9..ea1765c 100644 (file)
@@ -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<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->args[0]));
   break;
 
-case SIMCALL_PROCESS_ON_EXIT:
-  SIMIX_process_on_exit(simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<int_f_pvoid_pvoid_t>(simcall->args[1]), simgrid::simix::unmarshal<void*>(simcall->args[2]));
-  SIMIX_simcall_answer(simcall);
-  break;
-
 case SIMCALL_COMM_IPROBE:
   simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->result, simcall_HANDLER_comm_iprobe(simcall, simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1]), simgrid::simix::unmarshal<simix_match_func_t>(simcall->args[2]), simgrid::simix::unmarshal<void*>(simcall->args[3])));
   SIMIX_simcall_answer(simcall);
index 0801732..c72d961 100644 (file)
@@ -44,8 +44,6 @@ boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> execution_parallel_sta
 int           execution_wait(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution) [[block]];
 int           execution_test(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution) [[block]];
 
-void          process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data) [[nohandler]];
-
 boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> 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<simgrid::kernel::activity::ActivityImpl> 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);