+ simgrid::kernel::activity::ExecImpl::on_creation.connect([](simgrid::kernel::activity::ExecImpl& 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();
+
+ host->extension<HostLoad>()->add_activity(&activity);
+ 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_DEBUG("HostLoad plugin currently does not support executions on several hosts");
+ }
+ });
+ simgrid::kernel::activity::ExecImpl::on_completion.connect([](simgrid::kernel::activity::ExecImpl 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();
+
+ host->extension<HostLoad>()->update();
+ }
+ else { // This runs on multiple hosts
+ XBT_DEBUG("HostLoad plugin currently does not support executions on several hosts");
+ }
+ });