Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Wrap (xbt_main_func_t, argc, argv) in a std::function everywhere
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 20 May 2016 13:37:26 +0000 (15:37 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Mon, 23 May 2016 07:05:21 +0000 (09:05 +0200)
SIMIX_process_get_code() is a casuality of this refactoring: it does
not make sens in this design.

include/simgrid/simix.h
include/simgrid/simix.hpp
src/msg/msg_private.h
src/msg/msg_process.cpp
src/simix/smx_host.cpp
src/simix/smx_host_private.h
src/simix/smx_process.cpp
src/simix/smx_process_private.h
src/surf/sg_platf.cpp

index f0de3ed..bc07ffe 100644 (file)
@@ -223,7 +223,6 @@ XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
 XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
 XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
 XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data);
 XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
 XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
 XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data);
-XBT_PUBLIC(xbt_main_func_t) SIMIX_process_get_code(void);
 
 /****************************** Communication *********************************/
 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_synchro_t, void*, size_t));
 
 /****************************** Communication *********************************/
 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_synchro_t, void*, size_t));
index cf51596..cc08c5e 100644 (file)
@@ -296,11 +296,10 @@ XBT_PUBLIC(void) create_maestro(std::function<void()> code);
  */
 typedef smx_process_t (*smx_creation_func_t) (
                                       /* name */ const char*,
  */
 typedef smx_process_t (*smx_creation_func_t) (
                                       /* name */ const char*,
-                                      /* code */ xbt_main_func_t,
+                                      std::function<void()> code,
                                       /* userdata */ void*,
                                       /* hostname */ const char*,
                                       /* kill_time */ double,
                                       /* userdata */ void*,
                                       /* hostname */ const char*,
                                       /* kill_time */ double,
-                                      simgrid::simix::args args,
                                       /* props */ xbt_dict_t,
                                       /* auto_restart */ int,
                                       /* parent_process */ smx_process_t);
                                       /* props */ xbt_dict_t,
                                       /* auto_restart */ int,
                                       /* parent_process */ smx_process_t);
@@ -309,11 +308,10 @@ extern "C"
 XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
 
 XBT_PUBLIC(smx_process_t) simcall_process_create(const char *name,
 XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
 
 XBT_PUBLIC(smx_process_t) simcall_process_create(const char *name,
-                                          xbt_main_func_t code,
+                                          std::function<void()> code,
                                           void *data,
                                           const char *hostname,
                                           double kill_time,
                                           void *data,
                                           const char *hostname,
                                           double kill_time,
-                                          simgrid::simix::args args,
                                           xbt_dict_t properties,
                                           int auto_restart);
 
                                           xbt_dict_t properties,
                                           int auto_restart);
 
index 0d004f7..bb771f3 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef METASIMGRID_PRIVATE_H
 #define METASIMGRID_PRIVATE_H
 
 #ifndef METASIMGRID_PRIVATE_H
 #define METASIMGRID_PRIVATE_H
 
+#include <functional>
+
 #include "simgrid/msg.h"
 #include "simgrid/simix.h"
 #include "src/include/surf/surf.h"
 #include "simgrid/msg.h"
 #include "simgrid/simix.h"
 #include "src/include/surf/surf.h"
@@ -139,9 +141,8 @@ XBT_PRIVATE void __MSG_file_destroy(msg_file_priv_t host);
 
 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
 XBT_PRIVATE smx_process_t MSG_process_create_from_SIMIX(const char *name,
 
 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
 XBT_PRIVATE smx_process_t MSG_process_create_from_SIMIX(const char *name,
-                                   xbt_main_func_t code, void *data,
+                                   std::function<void()> code, void *data,
                                    const char *hostname, double kill_time,
                                    const char *hostname, double kill_time,
-                                   simgrid::simix::args args,
                                    xbt_dict_t properties, int auto_restart,
                                    smx_process_t parent_process);
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_synchro_t comm, void* buff, size_t buff_size);
                                    xbt_dict_t properties, int auto_restart,
                                    smx_process_t parent_process);
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_synchro_t comm, void* buff, size_t buff_size);
@@ -191,8 +192,7 @@ XBT_PRIVATE void TRACE_msg_vm_end(msg_vm_t vm);
 SG_END_DECL()
 
 XBT_PUBLIC(msg_process_t) MSG_process_create_with_environment(
 SG_END_DECL()
 
 XBT_PUBLIC(msg_process_t) MSG_process_create_with_environment(
-  const char *name, xbt_main_func_t code, void *data,
-  msg_host_t host, simgrid::simix::args args,
-  xbt_dict_t properties);
+  const char *name, std::function<void()> code, void *data,
+  msg_host_t host, xbt_dict_t properties);
 
 #endif
 
 #endif
index 6ca8e3a..41a5263 100644 (file)
@@ -4,6 +4,8 @@
 /* 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 <functional>
+
 #include "msg_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "msg_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -52,13 +54,14 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc)
 }
 
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
 }
 
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
-smx_process_t MSG_process_create_from_SIMIX(const char *name, xbt_main_func_t code, void *data, const char *hostname,
-                                            double kill_time, simgrid::simix::args args, xbt_dict_t properties,
-                                            int auto_restart, smx_process_t parent_process)
+smx_process_t MSG_process_create_from_SIMIX(
+  const char *name, std::function<void()> code, void *data, const char *hostname,
+  double kill_time, xbt_dict_t properties,
+  int auto_restart, smx_process_t parent_process)
 {
   msg_host_t host = MSG_host_by_name(hostname);
   msg_process_t p = MSG_process_create_with_environment(
 {
   msg_host_t host = MSG_host_by_name(hostname);
   msg_process_t p = MSG_process_create_with_environment(
-    name, code, data, host, args.argc(), args.to_argv(), properties);
+    name, std::move(code), data, host, properties);
   if (p) {
     MSG_process_set_kill_time(p,kill_time);
     MSG_process_auto_restart_set(p,auto_restart);
   if (p) {
     MSG_process_set_kill_time(p,kill_time);
     MSG_process_auto_restart_set(p,auto_restart);
@@ -128,8 +131,9 @@ msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_
 msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
                                                   int argc, char **argv, xbt_dict_t properties)
 {
 msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
                                                   int argc, char **argv, xbt_dict_t properties)
 {
-  msg_process_t res = MSG_process_create_with_environment(name, code, data, host,
-    simgrid::simix::args(argc, argv), properties);
+  msg_process_t res = MSG_process_create_with_environment(name,
+    simgrid::simix::wrap_main(code, argc, argv), data, host,
+    properties);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
@@ -137,9 +141,8 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
 }
 
 msg_process_t MSG_process_create_with_environment(
 }
 
 msg_process_t MSG_process_create_with_environment(
-  const char *name, xbt_main_func_t code, void *data,
-  msg_host_t host, simgrid::simix::args args,
-  xbt_dict_t properties)
+  const char *name, std::function<void()> code, void *data,
+  msg_host_t host, xbt_dict_t properties)
 {
   xbt_assert(code != NULL && host != NULL, "Invalid parameters: host and code params must not be NULL");
   simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
 {
   xbt_assert(code != NULL && host != NULL, "Invalid parameters: host and code params must not be NULL");
   simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
@@ -155,7 +158,7 @@ msg_process_t MSG_process_create_with_environment(
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
   process = simcall_process_create(
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
   process = simcall_process_create(
-    name, code, simdata, sg_host_get_name(host), -1, std::move(args), properties, 0);
+    name, std::move(code), simdata, sg_host_get_name(host), -1,  properties, 0);
 
   if (!process) {
     /* Undo everything we have just changed */
 
   if (!process) {
     /* Undo everything we have just changed */
index d4684dd..cf092ea 100644 (file)
@@ -57,7 +57,6 @@ void SIMIX_host_on(sg_host_t h)
                                               NULL,
                                               arg->hostname,
                                               arg->kill_time,
                                               NULL,
                                               arg->hostname,
                                               arg->kill_time,
-                                              arg->args,
                                               arg->properties,
                                               arg->auto_restart,
                                               NULL);
                                               arg->properties,
                                               arg->auto_restart,
                                               NULL);
@@ -67,7 +66,6 @@ void SIMIX_host_on(sg_host_t h)
                                NULL,
                                arg->hostname,
                                arg->kill_time,
                                NULL,
                                arg->hostname,
                                arg->kill_time,
-                               arg->args,
                                arg->properties,
                                arg->auto_restart);
       }
                                arg->properties,
                                arg->auto_restart);
       }
@@ -167,26 +165,20 @@ void _SIMIX_host_free_process_arg(void *data)
  * The processes will only be restarted once, meaning that you will have to register the process
  * again to restart the process again.
  */
  * The processes will only be restarted once, meaning that you will have to register the process
  * again to restart the process again.
  */
-void SIMIX_host_add_auto_restart_process(sg_host_t host,
-                                         const char *name,
-                                         xbt_main_func_t code,
-                                         void *data,
-                                         const char *hostname,
-                                         double kill_time,
-                                         int argc, char **argv,
-                                         xbt_dict_t properties,
-                                         int auto_restart)
+void SIMIX_host_add_auto_restart_process(
+  sg_host_t host, const char *name, std::function<void()> code,
+  void* data, const char *hostname, double kill_time,
+  xbt_dict_t properties, int auto_restart)
 {
   if (!sg_host_simix(host)->auto_restart_processes) {
     sg_host_simix(host)->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg);
   }
   smx_process_arg_t arg = new simgrid::simix::ProcessArg();
   arg->name = name;
 {
   if (!sg_host_simix(host)->auto_restart_processes) {
     sg_host_simix(host)->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg);
   }
   smx_process_arg_t arg = new simgrid::simix::ProcessArg();
   arg->name = name;
-  arg->code = code;
+  arg->code = std::move(code);
   arg->data = data;
   arg->hostname = hostname;
   arg->kill_time = kill_time;
   arg->data = data;
   arg->hostname = hostname;
   arg->kill_time = kill_time;
-  arg->args.assign(argc, argv);
   arg->properties = properties;
   arg->auto_restart = auto_restart;
 
   arg->properties = properties;
   arg->auto_restart = auto_restart;
 
@@ -216,17 +208,15 @@ void SIMIX_host_autorestart(sg_host_t host)
                                             NULL,
                                             arg->hostname,
                                             arg->kill_time,
                                             NULL,
                                             arg->hostname,
                                             arg->kill_time,
-                                            arg->args,
                                             arg->properties,
                                             arg->auto_restart,
                                             NULL);
     } else {
       simcall_process_create(arg->name.c_str(),
                                             arg->properties,
                                             arg->auto_restart,
                                             NULL);
     } else {
       simcall_process_create(arg->name.c_str(),
-                             (xbt_main_func_t) arg->code,
+                             arg->code,
                              NULL,
                              arg->hostname,
                              arg->kill_time,
                              NULL,
                              arg->hostname,
                              arg->kill_time,
-                             arg->args,
                              arg->properties,
                              arg->auto_restart);
     }
                              arg->properties,
                              arg->auto_restart);
     }
index eb8b7e6..bac4f9f 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef _SIMIX_HOST_PRIVATE_H
 #define _SIMIX_HOST_PRIVATE_H
 
 #ifndef _SIMIX_HOST_PRIVATE_H
 #define _SIMIX_HOST_PRIVATE_H
 
+#include <functional>
+
 #include <xbt/base.h>
 
 #include "simgrid/simix.h"
 #include <xbt/base.h>
 
 #include "simgrid/simix.h"
@@ -29,11 +31,10 @@ XBT_PRIVATE void SIMIX_host_destroy(void *host);
 
 XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host,
                                          const char *name,
 
 XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host,
                                          const char *name,
-                                         xbt_main_func_t code,
+                                         std::function<void()> code,
                                          void *data,
                                          const char *hostname,
                                          double kill_time,
                                          void *data,
                                          const char *hostname,
                                          double kill_time,
-                                         int argc, char **argv,
                                          xbt_dict_t properties,
                                          int auto_restart);
 
                                          xbt_dict_t properties,
                                          int auto_restart);
 
index f77724d..72651d2 100644 (file)
@@ -194,7 +194,7 @@ void SIMIX_process_stop(smx_process_t arg) {
                                         arg->code, arg->data,
                                         sg_host_get_name(arg->host),
                                         SIMIX_timer_get_date(arg->kill_timer),
                                         arg->code, arg->data,
                                         sg_host_get_name(arg->host),
                                         SIMIX_timer_get_date(arg->kill_timer),
-                                        arg->args.argc(), arg->args.argv(), arg->properties,
+                                        arg->properties,
                                         arg->auto_restart);
   }
   XBT_DEBUG("Process %s (%s) is dead",
                                         arg->auto_restart);
   }
   XBT_DEBUG("Process %s (%s) is dead",
@@ -202,20 +202,15 @@ void SIMIX_process_stop(smx_process_t arg) {
   arg->context->stop();
 }
 
   arg->context->stop();
 }
 
-void* simcall_HANDLER_process_create(smx_simcall_t simcall,
-                          const char *name,
-                          xbt_main_func_t code,
-                          void *data,
-                          const char *hostname,
-                          double kill_time,
-                          int argc, char **argv,
-                          xbt_dict_t properties,
-                          int auto_restart)
+void* simcall_HANDLER_process_create(
+  smx_simcall_t simcall, const char *name, xbt_main_func_t code,
+  void *data, const char *hostname, double kill_time,
+  int argc, char **argv, xbt_dict_t properties,
+  int auto_restart)
 {
 {
-  simgrid::simix::args args(argc, argv);
-  void* res = SIMIX_process_create(name, code, data, hostname,
-                       kill_time, std::move(args), properties, auto_restart,
-                       simcall->issuer);
+  void* res = SIMIX_process_create(
+    name, simgrid::simix::wrap_main(code, argc, argv), data, hostname,
+    kill_time, properties, auto_restart, simcall->issuer);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
@@ -238,11 +233,10 @@ static void kill_process(void* process)
  */
 smx_process_t SIMIX_process_create(
                           const char *name,
  */
 smx_process_t SIMIX_process_create(
                           const char *name,
-                          xbt_main_func_t code,
+                          std::function<void()> code,
                           void *data,
                           const char *hostname,
                           double kill_time,
                           void *data,
                           const char *hostname,
                           double kill_time,
-                          simgrid::simix::args args,
                           xbt_dict_t properties,
                           int auto_restart,
                           smx_process_t parent_process)
                           xbt_dict_t properties,
                           int auto_restart,
                           smx_process_t parent_process)
@@ -260,7 +254,7 @@ smx_process_t SIMIX_process_create(
   else {
     process = new simgrid::simix::Process();
 
   else {
     process = new simgrid::simix::Process();
 
-    xbt_assert(((code != NULL) && (host != NULL)), "Invalid parameters");
+    xbt_assert(code && host != NULL, "Invalid parameters");
     /* Process data */
     process->pid = simix_process_maxpid++;
     process->name = std::string(name);
     /* Process data */
     process->pid = simix_process_maxpid++;
     process->name = std::string(name);
@@ -291,11 +285,10 @@ smx_process_t SIMIX_process_create(
     /* Process data for auto-restart */
     process->auto_restart = auto_restart;
     process->code = code;
     /* Process data for auto-restart */
     process->auto_restart = auto_restart;
     process->code = code;
-    process->args = args;
 
     XBT_VERB("Create context %s", process->name.c_str());
     process->context = SIMIX_context_new(
 
     XBT_VERB("Create context %s", process->name.c_str());
     process->context = SIMIX_context_new(
-      simgrid::simix::wrap_main(code, std::move(args)),
+      std::move(code),
       simix_global->cleanup_process_function, process);
 
     process->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t));
       simix_global->cleanup_process_function, process);
 
     process->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t));
@@ -728,10 +721,6 @@ sg_host_t SIMIX_process_get_host(smx_process_t process)
   return process->host;
 }
 
   return process->host;
 }
 
-xbt_main_func_t SIMIX_process_get_code(void){
-  return SIMIX_process_self()->code;
-}
-
 /* needs to be public and without simcall because it is called
    by exceptions and logging events */
 const char* SIMIX_process_self_get_name(void) {
 /* needs to be public and without simcall because it is called
    by exceptions and logging events */
 const char* SIMIX_process_self_get_name(void) {
@@ -1002,7 +991,6 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer)
   arg.data = process->data;
   arg.properties = NULL;
   arg.auto_restart = process->auto_restart;
   arg.data = process->data;
   arg.properties = NULL;
   arg.auto_restart = process->auto_restart;
-  arg.args = process->args;
 
   //kill the old process
   SIMIX_process_kill(process, issuer);
 
   //kill the old process
   SIMIX_process_kill(process, issuer);
@@ -1010,16 +998,14 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer)
   //start the new process
   if (simix_global->create_process_function)
     return simix_global->create_process_function(
   //start the new process
   if (simix_global->create_process_function)
     return simix_global->create_process_function(
-      arg.name.c_str(), arg.code, arg.data,
+      arg.name.c_str(), std::move(arg.code), arg.data,
       arg.hostname, arg.kill_time,
       arg.hostname, arg.kill_time,
-      arg.args,
       arg.properties, arg.auto_restart,
       nullptr);
   else
     return simcall_process_create(
       arg.properties, arg.auto_restart,
       nullptr);
   else
     return simcall_process_create(
-      arg.name.c_str(), arg.code, arg.data,
+      arg.name.c_str(), std::move(arg.code), arg.data,
       arg.hostname, arg.kill_time,
       arg.hostname, arg.kill_time,
-      arg.args,
       arg.properties, arg.auto_restart);
 }
 
       arg.properties, arg.auto_restart);
 }
 
@@ -1027,21 +1013,18 @@ void SIMIX_segment_index_set(smx_process_t proc, int index){
   proc->segment_index = index;
 }
 
   proc->segment_index = index;
 }
 
-smx_process_t simcall_process_create(const char *name,
-                                          xbt_main_func_t code,
-                                          void *data,
-                                          const char *hostname,
-                                          double kill_time,
-                                          simgrid::simix::args args,
-                                          xbt_dict_t properties,
-                                          int auto_restart)
+smx_process_t simcall_process_create(
+  const char *name, std::function<void()> code, void *data,
+  const char *hostname, double kill_time,
+  xbt_dict_t properties, int auto_restart)
 {
   if (name == nullptr)
     name = "";
   smx_process_t self = SIMIX_process_self();
   return simgrid::simix::kernel([&] {
 {
   if (name == nullptr)
     name = "";
   smx_process_t self = SIMIX_process_self();
   return simgrid::simix::kernel([&] {
-    return SIMIX_process_create(name, code, data, hostname,
-          kill_time, std::move(args), properties, auto_restart,
+    return SIMIX_process_create(name,
+          std::move(code), data, hostname,
+          kill_time, properties, auto_restart,
           self);
   });
 }
\ No newline at end of file
           self);
   });
 }
\ No newline at end of file
index 3a3db8d..22af111 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef _SIMIX_PROCESS_PRIVATE_H
 #define _SIMIX_PROCESS_PRIVATE_H
 
 #ifndef _SIMIX_PROCESS_PRIVATE_H
 #define _SIMIX_PROCESS_PRIVATE_H
 
+#include <functional>
 #include <string>
 
 #include <xbt/base.h>
 #include <string>
 
 #include <xbt/base.h>
@@ -26,8 +27,7 @@ namespace simix {
 class ProcessArg {
 public:
   std::string name;
 class ProcessArg {
 public:
   std::string name;
-  xbt_main_func_t code = nullptr;
-  simgrid::simix::args args;
+  std::function<void()> code;
   void *data = nullptr;
   const char *hostname = nullptr;
   double kill_time = 0.0;
   void *data = nullptr;
   const char *hostname = nullptr;
   double kill_time = 0.0;
@@ -65,8 +65,7 @@ public:
   void *data = nullptr;    /* kept for compatibility, it should be replaced with moddata */
   xbt_dynar_t on_exit = nullptr; /* list of functions executed when the process dies */
 
   void *data = nullptr;    /* kept for compatibility, it should be replaced with moddata */
   xbt_dynar_t on_exit = nullptr; /* list of functions executed when the process dies */
 
-  xbt_main_func_t code = nullptr;
-  simgrid::simix::args args;
+  std::function<void()> code;
   smx_timer_t kill_timer = nullptr;
   int segment_index = 0;    /*Reference to an SMPI process' data segment. Default value is -1 if not in SMPI context*/
 };
   smx_timer_t kill_timer = nullptr;
   int segment_index = 0;    /*Reference to an SMPI process' data segment. Default value is -1 if not in SMPI context*/
 };
@@ -82,11 +81,10 @@ SG_BEGIN_DECL()
 
 XBT_PRIVATE smx_process_t SIMIX_process_create(
                           const char *name,
 
 XBT_PRIVATE smx_process_t SIMIX_process_create(
                           const char *name,
-                          xbt_main_func_t code,
+                          std::function<void()> code,
                           void *data,
                           const char *hostname,
                           double kill_time,
                           void *data,
                           const char *hostname,
                           double kill_time,
-                          simgrid::simix::args args,
                           xbt_dict_t properties,
                           int auto_restart,
                           smx_process_t parent_process);
                           xbt_dict_t properties,
                           int auto_restart,
                           smx_process_t parent_process);
index 35cd58e..5f7f50d 100644 (file)
@@ -572,15 +572,16 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
   double kill_time  = process->kill_time;
   int auto_restart = process->on_failure == SURF_PROCESS_ON_FAILURE_DIE ? 0 : 1;
 
   double kill_time  = process->kill_time;
   int auto_restart = process->on_failure == SURF_PROCESS_ON_FAILURE_DIE ? 0 : 1;
 
+  std::function<void()> code = simgrid::simix::wrap_main(parse_code, process->argc, process->argv);
+
   smx_process_arg_t arg = NULL;
   smx_process_t process_created = NULL;
 
   arg = new simgrid::simix::ProcessArg();
   arg->name = std::string(process->argv[0]);
   smx_process_arg_t arg = NULL;
   smx_process_t process_created = NULL;
 
   arg = new simgrid::simix::ProcessArg();
   arg->name = std::string(process->argv[0]);
-  arg->code = parse_code;
+  arg->code = code;
   arg->data = NULL;
   arg->hostname = sg_host_get_name(host);
   arg->data = NULL;
   arg->hostname = sg_host_get_name(host);
-  arg->args.assign(process->argc, process->argv);
   arg->kill_time = kill_time;
   arg->properties = current_property_set;
   if (!sg_host_simix(host)->boot_processes)
   arg->kill_time = kill_time;
   arg->properties = current_property_set;
   if (!sg_host_simix(host)->boot_processes)
@@ -589,12 +590,12 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
   xbt_dynar_push_as(sg_host_simix(host)->boot_processes,smx_process_arg_t,arg);
 
   if (start_time > SIMIX_get_clock()) {
   xbt_dynar_push_as(sg_host_simix(host)->boot_processes,smx_process_arg_t,arg);
 
   if (start_time > SIMIX_get_clock()) {
+
     arg = new simgrid::simix::ProcessArg();
     arg->name = std::string(process->argv[0]);
     arg = new simgrid::simix::ProcessArg();
     arg->name = std::string(process->argv[0]);
-    arg->code = parse_code;
+    arg->code = std::move(code);
     arg->data = NULL;
     arg->hostname = sg_host_get_name(host);
     arg->data = NULL;
     arg->hostname = sg_host_get_name(host);
-    arg->args.assign(process->argc, process->argv);
     arg->kill_time = kill_time;
     arg->properties = current_property_set;
 
     arg->kill_time = kill_time;
     arg->properties = current_property_set;
 
@@ -604,11 +605,10 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
       smx_process_arg_t arg = static_cast<smx_process_arg_t>(p);
       simix_global->create_process_function(
                                             arg->name.c_str(),
       smx_process_arg_t arg = static_cast<smx_process_arg_t>(p);
       simix_global->create_process_function(
                                             arg->name.c_str(),
-                                            arg->code,
+                                            std::move(arg->code),
                                             arg->data,
                                             arg->hostname,
                                             arg->kill_time,
                                             arg->data,
                                             arg->hostname,
                                             arg->kill_time,
-                                            std::move(arg->args),
                                             arg->properties,
                                             arg->auto_restart,
                                             NULL);
                                             arg->properties,
                                             arg->auto_restart,
                                             NULL);
@@ -620,18 +620,13 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
 
     if (simix_global->create_process_function)
       process_created = simix_global->create_process_function(
 
     if (simix_global->create_process_function)
       process_created = simix_global->create_process_function(
-          arg->name.c_str(),
-                                            parse_code,
-                                            NULL,
-                                            sg_host_get_name(host),
-                                            kill_time,
-                                            arg->args,
-                                            current_property_set,
-                                            auto_restart, NULL);
+          arg->name.c_str(), std::move(code), NULL,
+          sg_host_get_name(host), kill_time,
+          current_property_set, auto_restart, NULL);
     else
       process_created = simcall_process_create(
     else
       process_created = simcall_process_create(
-          arg->name.c_str(), parse_code, NULL, sg_host_get_name(host), kill_time,
-          arg->args, current_property_set,auto_restart);
+          arg->name.c_str(), std::move(code), NULL, sg_host_get_name(host), kill_time,
+          current_property_set,auto_restart);
 
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
     if (!process_created) {
 
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
     if (!process_created) {