* \param cleanup_func the function to call when the context stops
*/
smx_context_t SIMIX_context_new(
- xbt_main_func_t code, int argc, char **argv,
+ std::function<void()> code,
void_pfn_smxprocess_t cleanup_func,
smx_process_t simix_process)
{
if (!simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
return simix_global->context_factory->create_context(
- simgrid::simix::wrap_main(code, argc, argv), cleanup_func, simix_process);
+ std::move(code), cleanup_func, simix_process);
}
namespace simgrid {
#ifndef _SIMIX_PRIVATE_H
#define _SIMIX_PRIVATE_H
+#include <functional>
+
#include "src/internal_config.h"
#include "simgrid/simix.h"
#include "surf/surf.h"
XBT_PRIVATE void SIMIX_context_mod_exit(void);
XBT_PRIVATE smx_context_t SIMIX_context_new(
- xbt_main_func_t code, int argc, char **argv,
+ std::function<void()> code,
void_pfn_smxprocess_t cleanup_func,
smx_process_t simix_process);
XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx);
if (!code) {
- maestro->context = SIMIX_context_new(NULL, 0, nullptr, NULL, maestro);
+ maestro->context = SIMIX_context_new(std::function<void()>(), NULL, maestro);
} else {
if (!simix_global)
xbt_die("simix is not initialized, please call MSG_init first");
XBT_VERB("Create context %s", process->name);
- process->context = SIMIX_context_new(code, argc, argv, simix_global->cleanup_process_function, process);
+ process->context = SIMIX_context_new(
+ simgrid::simix::wrap_main(code, argc, argv),
+ simix_global->cleanup_process_function, process);
process->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t));
XBT_RUNNING_CTX_INITIALIZE(process->running_ctx);
xbt_parmap_thread_data_t data = (xbt_parmap_thread_data_t) arg;
xbt_parmap_t parmap = data->parmap;
unsigned round = 0;
- smx_context_t context = SIMIX_context_new(NULL, 0, NULL, NULL, NULL);
+ smx_context_t context = SIMIX_context_new(std::function<void()>(), NULL, NULL);
SIMIX_context_set_current(context);
XBT_DEBUG("New worker thread created");