SIMIX_storage_create(key, storage, NULL);
}
-static void (*maestro_code)(void*) = nullptr;
-static void* maestro_data = nullptr;
+static std::function<void()> maestro_code;
+
+namespace simgrid {
+namespace simix {
+
+XBT_PUBLIC(void) set_maestro(std::function<void()> code)
+{
+ maestro_code = std::move(code);
+}
+
+}
+}
void SIMIX_set_maestro(void (*code)(void*), void* data)
{
- maestro_code = code;
- maestro_data = data;
+ maestro_code = std::bind(code, data);
}
/**
// Either create a new context with maestro or create
// a context object with the current context mestro):
- SIMIX_maestro_create(maestro_code, maestro_data);
+ simgrid::simix::create_maestro(maestro_code);
/* context exception handlers */
__xbt_running_ctx_fetch = SIMIX_process_get_running_context;
}
}
-/**
- * \brief Creates and runs the maestro process
- */
-void SIMIX_maestro_create(void (*code)(void*), void* data)
+namespace simgrid {
+namespace simix {
+
+void create_maestro(std::function<void()> code)
{
smx_process_t maestro = NULL;
/* Create maestro process and intilialize it */
maestro->pid = simix_process_maxpid++;
maestro->ppid = -1;
maestro->name = (char*) "";
- maestro->data = data;
+ maestro->data = nullptr;
maestro->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t));
XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx);
if (!simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
maestro->context =
- simix_global->context_factory->create_maestro(
- std::bind(code, data), maestro);
+ simix_global->context_factory->create_maestro(code, maestro);
}
maestro->simcall.issuer = maestro;
simix_global->maestro_process = maestro;
}
+}
+}
+
+/**
+ * \brief Creates and runs the maestro process
+ */
+void SIMIX_maestro_create(void (*code)(void*), void* data)
+{
+ simgrid::simix::create_maestro(std::bind(code, data));
+}
+
/**
* \brief Stops a process.
*