Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove unused type definitions.
[simgrid.git] / src / plugins / host_load.cpp
index f0605a8..c529ac8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -176,21 +176,6 @@ static void on_host_change(simgrid::s4u::Host& host)
   host.extension<HostLoad>()->update();
 }
 
-/* This callback is called when an action (computation, idle, ...) terminates */
-static void on_action_state_change(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State /*previous*/)
-{
-  for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
-    simgrid::s4u::Host* host = cpu->get_host();
-
-    if (dynamic_cast<simgrid::s4u::VirtualMachine*>(host)) // Ignore virtual machines
-      return;
-
-    if (host != nullptr) {
-      host->extension<HostLoad>()->update();
-    }
-  }
-}
-
 /* **************************** Public interface *************************** */
 
 /** @brief Initializes the HostLoad plugin
@@ -222,8 +207,9 @@ void sg_host_load_plugin_init()
   simgrid::kernel::activity::ExecImpl::on_creation.connect([](simgrid::kernel::activity::ExecImplPtr activity){
     if (activity->host_ != nullptr) { // We only run on one host
       simgrid::s4u::Host* host = activity->host_;
-      if (dynamic_cast<simgrid::s4u::VirtualMachine*>(activity->host_))
-        host = dynamic_cast<simgrid::s4u::VirtualMachine*>(activity->host_)->get_pm();
+      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*
@@ -237,8 +223,9 @@ void sg_host_load_plugin_init()
   simgrid::kernel::activity::ExecImpl::on_completion.connect([](simgrid::kernel::activity::ExecImplPtr activity){
     if (activity->host_ != nullptr) { // We only run on one host
       simgrid::s4u::Host* host = activity->host_;
-      if (dynamic_cast<simgrid::s4u::VirtualMachine*>(activity->host_))
-        host = dynamic_cast<simgrid::s4u::VirtualMachine*>(activity->host_)->get_pm();
+      simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+      if (vm != nullptr)
+        host = vm->get_pm();
 
       host->extension<HostLoad>()->update();
     }