From 581fd733dd72630f9aa9b7528503693bd857bbbd Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 30 May 2018 10:48:18 +0200 Subject: [PATCH] simplification the previous state is NEVER used --- src/instr/instr_platform.cpp | 5 ++--- src/plugins/host_energy.cpp | 4 ++-- src/plugins/host_load.cpp | 4 ++-- src/surf/cpu_interface.cpp | 12 +++++------- src/surf/cpu_interface.hpp | 4 ++-- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 985c506ab1..a2adf5e3c6 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -232,8 +232,7 @@ static void instr_host_on_speed_change(simgrid::s4u::Host& host) ->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, - simgrid::kernel::resource::Action::State /* previous */) +static void instr_cpu_action_on_state_change(simgrid::surf::CpuAction* action) { simgrid::surf::Cpu* cpu = static_cast(action->get_variable()->get_constraint(0)->get_id()); TRACE_surf_resource_set_utilization("HOST", "power_used", cpu->get_cname(), action->get_category(), @@ -358,7 +357,7 @@ void instr_define_callbacks() } simgrid::s4u::NetZone::onCreation.connect(instr_netzone_on_creation); - simgrid::surf::CpuAction::onStateChange.connect(instr_cpu_action_on_state_change); + simgrid::surf::CpuAction::on_state_change.connect(instr_cpu_action_on_state_change); simgrid::s4u::Link::on_communication_state_change.connect(instr_link_on_communication_state_change); if (TRACE_actor_is_enabled()) { diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 42c9f8e4e5..c5d0f67801 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -381,7 +381,7 @@ static void onCreation(simgrid::s4u::Host& host) host.extension_set(new HostEnergy(&host)); } -static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State previous) +static void onActionStateChange(simgrid::surf::CpuAction* action) { for (simgrid::surf::Cpu* const& cpu : action->cpus()) { simgrid::s4u::Host* host = cpu->get_host(); @@ -462,7 +462,7 @@ void sg_host_energy_plugin_init() simgrid::s4u::Host::on_speed_change.connect(&onHostChange); simgrid::s4u::Host::on_destruction.connect(&onHostDestruction); simgrid::s4u::on_simulation_end.connect(&onSimulationEnd); - simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange); + simgrid::surf::CpuAction::on_state_change.connect(&onActionStateChange); } /** @ingroup plugin_energy diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index 0ca6a98f18..69e2a0dc2b 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -149,7 +149,7 @@ static void onHostChange(simgrid::s4u::Host& host) } /* This callback is called when an action (computation, idle, ...) terminates */ -static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State /*previous*/) +static void onActionStateChange(simgrid::surf::CpuAction* action) { for (simgrid::surf::Cpu* const& cpu : action->cpus()) { simgrid::s4u::Host* host = cpu->get_host(); @@ -184,7 +184,7 @@ void sg_host_load_plugin_init() host.extension_set(new HostLoad(&host)); }); - simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange); + simgrid::surf::CpuAction::on_state_change.connect(&onActionStateChange); simgrid::s4u::Host::on_state_change.connect(&onHostChange); simgrid::s4u::Host::on_speed_change.connect(&onHostChange); } diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index eba8890457..98bb02c9c9 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -172,26 +172,24 @@ void CpuAction::update_remains_lazy(double now) set_last_value(get_variable()->get_value()); } -simgrid::xbt::signal CpuAction::onStateChange; +simgrid::xbt::signal CpuAction::on_state_change; void CpuAction::suspend(){ - Action::State previous = get_state(); - onStateChange(this, previous); + on_state_change(this); Action::suspend(); } void CpuAction::resume(){ - Action::State previous = get_state(); - onStateChange(this, previous); + on_state_change(this); Action::resume(); } void CpuAction::set_state(Action::State state) { - Action::State previous = get_state(); Action::set_state(state); - onStateChange(this, previous); + on_state_change(this); } + /** @brief returns a list of all CPUs that this action is using */ std::list CpuAction::cpus() { std::list retlist; diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index fed276a697..8eb5a34318 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -168,9 +168,9 @@ protected: 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, simgrid::kernel::resource::Action::State previous)` + * Signature: `void(CpuAction *action)` */ - static simgrid::xbt::signal onStateChange; + static simgrid::xbt::signal on_state_change; /** @brief Signal emitted when the action share changes (amount of flops it gets) * Signature: `void(CpuAction *action)` */ -- 2.20.1