Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "simplification"
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 23 Jun 2018 20:32:16 +0000 (22:32 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 23 Jun 2018 20:35:39 +0000 (22:35 +0200)
The "previous" parameter is not used by our own callbacks, but may
reveal useful to our users.

This reverts commit 581fd733dd72630f9aa9b7528503693bd857bbbd.

src/instr/instr_platform.cpp
src/plugins/host_energy.cpp
src/plugins/host_load.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp

index 44d2276..7a6c2b0 100644 (file)
@@ -232,7 +232,8 @@ static void instr_host_on_speed_change(simgrid::s4u::Host& host)
       ->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
 }
 
       ->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
 }
 
-static void instr_cpu_action_on_state_change(simgrid::surf::CpuAction* action)
+static void instr_cpu_action_on_state_change(simgrid::surf::CpuAction* action,
+                                             simgrid::kernel::resource::Action::State /* previous */)
 {
   simgrid::surf::Cpu* cpu = static_cast<simgrid::surf::Cpu*>(action->get_variable()->get_constraint(0)->get_id());
   TRACE_surf_resource_set_utilization("HOST", "power_used", cpu->get_cname(), action->get_category(),
 {
   simgrid::surf::Cpu* cpu = static_cast<simgrid::surf::Cpu*>(action->get_variable()->get_constraint(0)->get_id());
   TRACE_surf_resource_set_utilization("HOST", "power_used", cpu->get_cname(), action->get_category(),
index 579af03..6216242 100644 (file)
@@ -384,7 +384,7 @@ static void on_creation(simgrid::s4u::Host& host)
   host.extension_set(new HostEnergy(&host));
 }
 
   host.extension_set(new HostEnergy(&host));
 }
 
-static void on_action_state_change(simgrid::surf::CpuAction* action)
+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();
 {
   for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
     simgrid::s4u::Host* host = cpu->get_host();
index dd1d428..86d6f1a 100644 (file)
@@ -132,7 +132,7 @@ static void on_host_change(simgrid::s4u::Host& host)
 }
 
 /* This callback is called when an action (computation, idle, ...) terminates */
 }
 
 /* This callback is called when an action (computation, idle, ...) terminates */
-static void on_action_state_change(simgrid::surf::CpuAction* action)
+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();
 {
   for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
     simgrid::s4u::Host* host = cpu->get_host();
index ace74b4..0f1a3ab 100644 (file)
@@ -166,24 +166,26 @@ void CpuAction::update_remains_lazy(double now)
   set_last_value(get_variable()->get_value());
 }
 
   set_last_value(get_variable()->get_value());
 }
 
-simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> CpuAction::on_state_change;
+simgrid::xbt::signal<void(simgrid::surf::CpuAction*, kernel::resource::Action::State)> CpuAction::on_state_change;
 
 void CpuAction::suspend(){
 
 void CpuAction::suspend(){
-  on_state_change(this);
+  Action::State previous = get_state();
+  on_state_change(this, previous);
   Action::suspend();
 }
 
 void CpuAction::resume(){
   Action::suspend();
 }
 
 void CpuAction::resume(){
-  on_state_change(this);
+  Action::State previous = get_state();
+  on_state_change(this, previous);
   Action::resume();
 }
 
 void CpuAction::set_state(Action::State state)
 {
   Action::resume();
 }
 
 void CpuAction::set_state(Action::State state)
 {
+  Action::State previous = get_state();
   Action::set_state(state);
   Action::set_state(state);
-  on_state_change(this);
+  on_state_change(this, previous);
 }
 }
-
 /** @brief returns a list of all CPUs that this action is using */
 std::list<Cpu*> CpuAction::cpus() {
   std::list<Cpu*> retlist;
 /** @brief returns a list of all CPUs that this action is using */
 std::list<Cpu*> CpuAction::cpus() {
   std::list<Cpu*> retlist;
index a1ce5a5..c9ce425 100644 (file)
@@ -163,13 +163,13 @@ protected:
 class XBT_PUBLIC CpuAction : public simgrid::kernel::resource::Action {
 public:
   /** @brief Signal emitted when the action state changes (ready/running/done, etc)
 class XBT_PUBLIC CpuAction : public simgrid::kernel::resource::Action {
 public:
   /** @brief Signal emitted when the action state changes (ready/running/done, etc)
-   *  Signature: `void(CpuAction *action)`
+   *  Signature: `void(CpuAction *action, simgrid::kernel::resource::Action::State previous)`
    */
    */
-  static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> on_state_change;
+  static simgrid::xbt::signal<void(simgrid::surf::CpuAction*, simgrid::kernel::resource::Action::State)> on_state_change;
   /** @brief Signal emitted when the action share changes (amount of flops it gets)
    *  Signature: `void(CpuAction *action)`
    */
   /** @brief Signal emitted when the action share changes (amount of flops it gets)
    *  Signature: `void(CpuAction *action)`
    */
-  static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> onShareChange;
+  static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> on_share_change;
 
   CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed) : Action(model, cost, failed) {}
   CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed, kernel::lmm::Variable* var)
 
   CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed) : Action(model, cost, failed) {}
   CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed, kernel::lmm::Variable* var)