-#include "simix/datatypes.h"
-#include "smx_smurf_private.h"
-
-/** @brief Process datatype */
-typedef struct s_smx_process {
- s_xbt_swag_hookup_t process_hookup;
- s_xbt_swag_hookup_t synchro_hookup; /* process_to_run or mutex->sleeping and co */
- s_xbt_swag_hookup_t host_proc_hookup;
- s_xbt_swag_hookup_t destroy_hookup;
-
- unsigned long pid;
- char *name; /**< @brief process name if any */
- smx_host_t smx_host; /* the host on which the process is running */
- smx_context_t context; /* the context (either uctx or thread) that executes the user function */
- xbt_running_ctx_t *running_ctx;
- int doexception:1;
- int blocked:1;
- int suspended:1;
- smx_host_t new_host; /* if not null, the host on which the process must migrate to */
- smx_action_t waiting_action; /* the current blocking action if any */
- xbt_fifo_t comms; /* the current non-blocking communication actions */
- xbt_dict_t properties;
- s_smx_req_t request;
- void *data; /* kept for compatibility, it should be replaced with moddata */
-
-} s_smx_process_t;
-
-typedef struct s_smx_process_arg {
- const char *name;
- xbt_main_func_t code;
- void *data;
- char *hostname;
- int argc;
- char **argv;
- double kill_time;
- xbt_dict_t properties;
-} s_smx_process_arg_t, *smx_process_arg_t;
-
-void SIMIX_process_create(smx_process_t *process,
+#include <functional>
+#include <string>
+
+#include <xbt/base.h>
+#include <xbt/string.hpp>
+
+#include <simgrid/simix.hpp>
+#include "simgrid/simix.h"
+#include "popping_private.h"
+
+typedef struct s_smx_process_exit_fun {
+ int_f_pvoid_pvoid_t fun;
+ void *arg;
+} s_smx_process_exit_fun_t, *smx_process_exit_fun_t;
+
+namespace simgrid {
+namespace simix {
+
+class ProcessArg {
+public:
+ std::string name;
+ std::function<void()> code;
+ void *data = nullptr;
+ const char *hostname = nullptr;
+ double kill_time = 0.0;
+ xbt_dict_t properties = nullptr;
+ bool auto_restart = false;
+};
+
+class Process {
+public:
+
+ // TODO, replace with boost intrusive container hooks
+ s_xbt_swag_hookup_t process_hookup = { nullptr, nullptr }; /* simix_global->process_list */
+ s_xbt_swag_hookup_t synchro_hookup = { nullptr, nullptr }; /* {mutex,cond,sem}->sleeping */
+ s_xbt_swag_hookup_t host_proc_hookup = { nullptr, nullptr }; /* smx_host->process_lis */
+ s_xbt_swag_hookup_t destroy_hookup = { nullptr, nullptr }; /* simix_global->process_to_destroy */
+
+ unsigned long pid = 0;
+ unsigned long ppid = 0;
+ simgrid::xbt::string name;
+ sg_host_t host = nullptr; /* the host on which the process is running */
+ smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */
+ xbt_running_ctx_t *running_ctx = nullptr;
+
+ // TODO, pack them
+ bool doexception = false;
+ bool blocked = false;
+ bool suspended = false;
+ bool auto_restart = false;
+
+ sg_host_t new_host = nullptr; /* if not null, the host on which the process must migrate to */
+ smx_synchro_t waiting_synchro = nullptr; /* the current blocking synchro if any */
+ xbt_fifo_t comms = nullptr; /* the current non-blocking communication synchros */
+ xbt_dict_t properties = nullptr;
+ s_smx_simcall_t simcall;
+ 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 */
+
+ 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*/
+};
+
+}
+}
+
+typedef simgrid::simix::ProcessArg *smx_process_arg_t;
+
+typedef simgrid::simix::Process* smx_process_t;
+
+SG_BEGIN_DECL()
+
+XBT_PRIVATE smx_process_t SIMIX_process_create(