X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ebbf93ef2f2d1164e90a579d18328a570fd67acb..c55f7a29931df2567c0830e45aa889040e54927c:/src/simix/smx_process.cpp diff --git a/src/simix/smx_process.cpp b/src/simix/smx_process.cpp index 65d1f6c271..0215582f18 100644 --- a/src/simix/smx_process.cpp +++ b/src/simix/smx_process.cpp @@ -139,10 +139,10 @@ void SIMIX_process_empty_trash(void) } } -/** - * \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 code) { smx_process_t maestro = NULL; /* Create maestro process and intilialize it */ @@ -150,7 +150,7 @@ void SIMIX_maestro_create(void (*code)(void*), void* data) 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); @@ -160,14 +160,24 @@ void SIMIX_maestro_create(void (*code)(void*), void* data) 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. * @@ -179,7 +189,7 @@ void SIMIX_process_stop(smx_process_t arg) { /* execute the on_exit functions */ SIMIX_process_on_exit_runall(arg); /* Add the process to the list of process to restart, only if the host is down */ - if (arg->auto_restart && arg->host->is_off()) { + if (arg->auto_restart && arg->host->isOff()) { SIMIX_host_add_auto_restart_process(arg->host,arg->name,arg->code, arg->data, sg_host_get_name(arg->host), SIMIX_timer_get_date(arg->kill_timer), @@ -258,7 +268,7 @@ smx_process_t SIMIX_process_create( XBT_DEBUG("Start process %s on host '%s'", name, hostname); - if (host->is_off()) { + if (host->isOff()) { int i; XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname); @@ -284,7 +294,7 @@ smx_process_t SIMIX_process_create( process->ppid = SIMIX_process_get_PID(parent_process); /* SMPI process have their own data segment and each other inherit from their father */ -#ifdef HAVE_SMPI +#if HAVE_SMPI if(smpi_privatize_global_variables){ if( parent_process->pid != 0){ SIMIX_segment_index_set(process, parent_process->segment_index); @@ -352,7 +362,7 @@ smx_process_t SIMIX_process_attach( sg_host_t host = sg_host_by_name(hostname); XBT_DEBUG("Attach process %s on host '%s'", name, hostname); - if (host->is_off()) { + if (host->isOff()) { XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname); return nullptr; @@ -373,7 +383,7 @@ smx_process_t SIMIX_process_attach( process->ppid = SIMIX_process_get_PID(parent_process); /* SMPI process have their own data segment and each other inherit from their father */ - #ifdef HAVE_SMPI + #if HAVE_SMPI if(smpi_privatize_global_variables){ if(parent_process->pid != 0){ SIMIX_segment_index_set(process, parent_process->segment_index); @@ -758,9 +768,9 @@ int SIMIX_process_get_PPID(smx_process_t self){ return self->ppid; } -void* SIMIX_process_self_get_data(smx_process_t self) +void* SIMIX_process_self_get_data() { - xbt_assert(self == SIMIX_process_self(), "This is not the current process"); + smx_process_t self = SIMIX_process_self(); if (!self) { return NULL; @@ -768,9 +778,9 @@ void* SIMIX_process_self_get_data(smx_process_t self) return SIMIX_process_get_data(self); } -void SIMIX_process_self_set_data(smx_process_t self, void *data) +void SIMIX_process_self_set_data(void *data) { - xbt_assert(self == SIMIX_process_self(), "This is not the current process"); + smx_process_t self = SIMIX_process_self(); SIMIX_process_set_data(self, data); } @@ -888,7 +898,7 @@ smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration) sg_host_t host = process->host; /* check if the host is active */ - if (host->is_off()) { + if (host->isOff()) { THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host)); } @@ -930,7 +940,7 @@ void SIMIX_post_process_sleep(smx_synchro_t synchro) THROW_IMPOSSIBLE; break; } - if (simcall->issuer->host->is_off()) { + if (simcall->issuer->host->isOff()) { simcall->issuer->context->iwannadie = 1; } simcall_process_sleep__set__result(simcall, state);