+ simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
+ if (activity.get_host_number() == 1) { // We only run on one host
+ simgrid::s4u::Host* host = activity.get_host();
+ simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+ if (vm != nullptr)
+ host = vm->get_pm();
+ xbt_assert(host != nullptr);
+ host->extension<HostLoad>()->add_activity(static_cast<simgrid::kernel::activity::ExecImpl*>(activity.get_impl()));
+ host->extension<HostLoad>()->update(); // If the system was idle until now, we need to update *before*
+ // this computation starts running so we can keep track of the
+ // idle time. (Communication operations don't trigger this hook!)
+ }
+ else { // This runs on multiple hosts
+ XBT_WARN("HostLoad plugin currently does not support executions on several hosts");
+ }
+ });
+ simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
+ if (activity.get_host_number() == 1) { // We only run on one host
+ simgrid::s4u::Host* host = activity.get_host();
+ simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+ if (vm != nullptr)
+ host = vm->get_pm();
+ xbt_assert(host != nullptr);
+ host->extension<HostLoad>()->update();
+ }
+ else { // This runs on multiple hosts
+ XBT_WARN("HostLoad plugin currently does not support executions on several hosts");
+ }
+ });