From: Martin Quinson Date: Thu, 17 May 2018 12:56:22 +0000 (+0200) Subject: inline SIMIX_host_off into s4u::Host->turnOff() X-Git-Tag: v3.20~215^2~7 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8e7ef5ba20700f883e5f2976399a51ba898f676a?hp=1d9d174e0e416ffd7be66189889a18bf3e21639b inline SIMIX_host_off into s4u::Host->turnOff() --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 9886e4dd96..57af3ba4d3 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -138,9 +138,6 @@ XBT_PUBLIC smx_actor_t SIMIX_process_attach(const char* name, void* data, const #endif XBT_PUBLIC void SIMIX_process_detach(); -/*********************************** Host *************************************/ -XBT_PUBLIC void SIMIX_host_off(sg_host_t host, smx_actor_t issuer); - /********************************* Process ************************************/ XBT_PUBLIC int SIMIX_process_count(); XBT_PUBLIC smx_actor_t SIMIX_process_self(); diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 17f9d904ae..9aa141c5b6 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -100,12 +100,27 @@ void Host::turnOn() } } +/** @brief Stop the host if it is on */ void Host::turnOff() { if (isOn()) { smx_actor_t self = SIMIX_process_self(); simgrid::simix::simcall([this, self] { - SIMIX_host_off(this, self); + simgrid::simix::Host* host = this->extension(); + + xbt_assert((host != nullptr), "Invalid parameters"); + + this->pimpl_cpu->turn_off(); + + /* Clean Simulator data */ + if (not host->process_list.empty()) { + for (auto& process : host->process_list) { + SIMIX_process_kill(&process, self); + XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", process.get_cname(), + process.host->get_cname(), self->get_cname()); + } + } + on_state_change(*this); }); } diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 3e9573a26e..0ff9a9e421 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -61,29 +61,6 @@ namespace simgrid { }} // namespaces -/** @brief Stop the host if it is on */ -void SIMIX_host_off(sg_host_t h, smx_actor_t issuer) -{ - simgrid::simix::Host* host = h->extension(); - - xbt_assert((host != nullptr), "Invalid parameters"); - - if (h->isOn()) { - h->pimpl_cpu->turn_off(); - - /* Clean Simulator data */ - if (not host->process_list.empty()) { - for (auto& process : host->process_list) { - SIMIX_process_kill(&process, issuer); - XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", process.get_cname(), - process.host->get_cname(), issuer->get_cname()); - } - } - } else { - XBT_INFO("Host %s is already off", h->get_cname()); - } -} - /* needs to be public and without simcall for exceptions and logging events */ const char* sg_host_self_get_name() {