X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e63dbc224bdb56acaae2aa36c1ac35bfbc1479f2..f06cff482686f7949ed7ea981cbceac138ce15c1:/src/simix/smx_host.cpp diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 8f80f02c70..d2d8550198 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -19,11 +19,37 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "SIMIX hosts"); namespace simgrid { namespace simix { + simgrid::xbt::Extension Host::EXTENSION_ID; + Host::Host() { + if (!EXTENSION_ID.valid()) + EXTENSION_ID = simgrid::s4u::Host::extension_create(); + simgrid::simix::ActorImpl act; process_list = xbt_swag_new(xbt_swag_offset(act, host_proc_hookup)); } + + Host::~Host() + { + /* Clean Simulator data */ + if (xbt_swag_size(process_list) != 0) { + char *msg = xbt_strdup("Shutting down host, but it's not empty:"); + char *tmp; + smx_actor_t process = nullptr; + + xbt_swag_foreach(process, process_list) { + tmp = bprintf("%s\n\t%s", msg, process->name.c_str()); + free(msg); + msg = tmp; + } + SIMIX_display_process_status(); + THROWF(arg_error, 0, "%s", msg); + } + xbt_dynar_free(&auto_restart_processes); + xbt_dynar_free(&boot_processes); + xbt_swag_free(process_list); + } } } @@ -97,39 +123,6 @@ void SIMIX_host_off(sg_host_t h, smx_actor_t issuer) } } -/** - * \brief Internal function to destroy a SIMIX host. - * - * \param h the host to destroy (a sg_host_t) - */ -void SIMIX_host_destroy(void *h) -{ - smx_host_priv_t host = static_cast(h); - - xbt_assert((host != nullptr), "Invalid parameters"); - - /* Clean Simulator data */ - if (xbt_swag_size(host->process_list) != 0) { - char *msg = xbt_strdup("Shutting down host, but it's not empty:"); - char *tmp; - smx_actor_t process = nullptr; - - xbt_swag_foreach(process, host->process_list) { - tmp = bprintf("%s\n\t%s", msg, process->name.c_str()); - free(msg); - msg = tmp; - } - SIMIX_display_process_status(); - THROWF(arg_error, 0, "%s", msg); - } - xbt_dynar_free(&host->auto_restart_processes); - xbt_dynar_free(&host->boot_processes); - xbt_swag_free(host->process_list); - - /* Clean host structure */ - delete host; -} - sg_host_t SIMIX_host_self() { smx_actor_t process = SIMIX_process_self();