Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix Host::execute to use *this as a host location, not the this_actor->get_host()
[simgrid.git] / src / s4u / s4u_Host.cpp
index f7590a0..670882c 100644 (file)
@@ -32,8 +32,9 @@ namespace s4u {
 #ifndef DOXYGEN
 xbt::signal<void(Host&)> Host::on_creation;
 xbt::signal<void(Host const&)> Host::on_destruction;
-xbt::signal<void(Host const&)> Host::on_state_change;
+xbt::signal<void(Host const&)> Host::on_onoff;
 xbt::signal<void(Host const&)> Host::on_speed_change;
+xbt::signal<void(kernel::resource::CpuAction&, kernel::resource::Action::State)> Host::on_exec_state_change;
 #endif
 
 Host* Host::set_cpu(kernel::resource::CpuImpl* cpu)
@@ -101,7 +102,8 @@ void Host::turn_on()
     kernel::actor::simcall_answered([this] {
       this->pimpl_cpu_->turn_on();
       this->pimpl_->turn_on();
-      on_state_change(*this);
+      on_onoff(*this);
+      on_this_onoff(*this);
     });
   }
 }
@@ -115,7 +117,8 @@ void Host::turn_off()
       this->pimpl_cpu_->turn_off();
       this->pimpl_->turn_off(self);
 
-      on_state_change(*this);
+      on_onoff(*this);
+      on_this_onoff(*this);
     });
   }
 }
@@ -168,7 +171,7 @@ std::pair<std::vector<Link*>, double> Host::route_to(const Host* dest) const
 {
   std::vector<kernel::resource::StandardLinkImpl*> linkImpls;
   std::vector<Link*> links;
-  double latency;
+  double latency = 0;
   this->route_to(dest, linkImpls, &latency);
   for (auto* l : linkImpls)
     links.push_back(l->get_iface());
@@ -417,7 +420,7 @@ void Host::execute(double flops) const
 
 void Host::execute(double flops, double priority) const
 {
-  this_actor::exec_init(flops)->set_priority(1 / priority)->start()->wait();
+  Exec::init()->set_flops_amount(flops)->set_host(const_cast<Host*>(this))->set_priority(1 / priority)->wait();
 }
 
 Host* Host::seal()
@@ -678,22 +681,6 @@ void sg_host_sendto(sg_host_t from, sg_host_t to, double byte_amount)
   simgrid::s4u::Comm::sendto(from, to, byte_amount);
 }
 
-/** @brief Displays debugging information about a host */
-void sg_host_dump(const_sg_host_t host) // XBT_ATTRIB_DEPRECATED_v335
-{
-  XBT_INFO("Displaying host %s", host->get_cname());
-  XBT_INFO("  - speed: %.0f", host->get_speed());
-  XBT_INFO("  - available speed: %.2f", sg_host_get_available_speed(host));
-  const std::unordered_map<std::string, std::string>* props = host->get_properties();
-
-  if (not props->empty()) {
-    XBT_INFO("  - properties:");
-    for (auto const& [key, value] : *props) {
-      XBT_INFO("    %s->%s", key.c_str(), value.c_str());
-    }
-  }
-}
-
 /** @brief Return the list of actors attached to a host.
  *
  * @param host a host