Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The creation of the pimpl needs no simcall
[simgrid.git] / src / plugins / host_energy.cpp
index 763b905..3a81ebe 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. */
@@ -497,8 +497,9 @@ void sg_host_energy_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<HostEnergy>()->update();
     }