From c0f3756528127131a1947179f56871657a084259 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 17 May 2018 22:26:52 +0200 Subject: [PATCH 1/1] UPPER_CASE the Action::State values (+ uniformity with s4u::Activity) --- include/simgrid/kernel/resource/Action.hpp | 11 ++++---- include/simgrid/kernel/resource/Model.hpp | 12 ++++---- src/kernel/activity/CommImpl.cpp | 10 +++---- src/kernel/activity/ExecImpl.cpp | 5 ++-- src/kernel/activity/SleepImpl.cpp | 4 +-- src/kernel/activity/SynchroIo.cpp | 4 +-- src/kernel/activity/SynchroRaw.cpp | 4 +-- src/kernel/resource/Action.cpp | 32 +++++++++++----------- src/kernel/resource/Model.cpp | 8 +++--- src/simix/ActorImpl.cpp | 2 +- src/simix/smx_network.cpp | 2 +- src/surf/cpu_cas01.cpp | 8 +++--- src/surf/cpu_interface.cpp | 10 +++---- src/surf/cpu_ti.cpp | 18 ++++++------ src/surf/network_cm02.cpp | 12 ++++---- src/surf/network_constant.cpp | 8 +++--- src/surf/network_ib.cpp | 2 +- src/surf/network_interface.cpp | 2 +- src/surf/network_ns3.cpp | 8 +++--- src/surf/ptask_L07.cpp | 8 +++--- src/surf/storage_n11.cpp | 6 ++-- src/surf/surf_c_bindings.cpp | 4 +-- teshsuite/surf/surf_usage/surf_usage.cpp | 16 +++++------ 23 files changed, 99 insertions(+), 97 deletions(-) diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index c8e20eb4bd..72a9435506 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -66,11 +66,12 @@ public: StateSet; enum class State { - inited, /**< Created, but not started yet */ - running, /**< Started, currently running */ - failed, /**< Completed (unsuccessfully: either the resource failed, or the action was canceled) */ - done, /**< Completed (successfully) */ - ignored /**< e.g. failure detectors, these infinite sleep actions that are put on resources which failure should be notified */ + INITED, /**< Created, but not started yet */ + STARTED, /**< Currently running */ + FAILED, /**< either the resource failed, or the action was canceled */ + FINISHED, /**< Successfully completed */ + IGNORED /**< e.g. failure detectors, these infinite sleep actions that are put on resources which failure should be + notified */ }; enum class SuspendStates { diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index 399a5073d7..9a614ca37f 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -34,14 +34,14 @@ public: /** @brief Get the set of [actions](@ref Action) in *inited* state */ Action::StateSet* get_inited_action_set() const { return inited_action_set_; } - /** @brief Get the set of [actions](@ref Action) in *running* state */ - Action::StateSet* get_running_action_set() const { return running_action_set_; } + /** @brief Get the set of [actions](@ref Action) in *started* state */ + Action::StateSet* get_started_action_set() const { return started_action_set_; } /** @brief Get the set of [actions](@ref Action) in *failed* state */ Action::StateSet* get_failed_action_set() const { return failed_action_set_; } - /** @brief Get the set of [actions](@ref Action) in *done* state */ - Action::StateSet* get_done_action_set() const { return done_action_set_; } + /** @brief Get the set of [actions](@ref Action) in *finished* state */ + Action::StateSet* get_finished_action_set() const { return finished_action_set_; } /** @brief Get the set of modified [actions](@ref Action) */ Action::ModifiedSet* get_modified_set() const; @@ -89,9 +89,9 @@ private: lmm::System* maxmin_system_ = nullptr; const UpdateAlgo update_algorithm_; Action::StateSet* inited_action_set_ = new Action::StateSet(); /**< Created not started */ - Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Started not done */ + Action::StateSet* started_action_set_ = new Action::StateSet(); /**< Started not done */ Action::StateSet* failed_action_set_ = new Action::StateSet(); /**< Done with failure */ - Action::StateSet* done_action_set_ = new Action::StateSet(); /**< Done successful */ + Action::StateSet* finished_action_set_ = new Action::StateSet(); /**< Done successful */ ActionHeap action_heap_; }; diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 7d9bd69694..8c2f838362 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -97,15 +97,15 @@ void simgrid::kernel::activity::CommImpl::cleanupSurf() void simgrid::kernel::activity::CommImpl::post() { /* Update synchro state */ - if (src_timeout && src_timeout->get_state() == simgrid::kernel::resource::Action::State::done) + if (src_timeout && src_timeout->get_state() == simgrid::kernel::resource::Action::State::FINISHED) state_ = SIMIX_SRC_TIMEOUT; - else if (dst_timeout && dst_timeout->get_state() == simgrid::kernel::resource::Action::State::done) + else if (dst_timeout && dst_timeout->get_state() == simgrid::kernel::resource::Action::State::FINISHED) state_ = SIMIX_DST_TIMEOUT; - else if (src_timeout && src_timeout->get_state() == simgrid::kernel::resource::Action::State::failed) + else if (src_timeout && src_timeout->get_state() == simgrid::kernel::resource::Action::State::FAILED) state_ = SIMIX_SRC_HOST_FAILURE; - else if (dst_timeout && dst_timeout->get_state() == simgrid::kernel::resource::Action::State::failed) + else if (dst_timeout && dst_timeout->get_state() == simgrid::kernel::resource::Action::State::FAILED) state_ = SIMIX_DST_HOST_FAILURE; - else if (surfAction_ && surfAction_->get_state() == simgrid::kernel::resource::Action::State::failed) { + else if (surfAction_ && surfAction_->get_state() == simgrid::kernel::resource::Action::State::FAILED) { state_ = SIMIX_LINK_FAILURE; } else state_ = SIMIX_DONE; diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 6cecccf6cf..a0e3cc2c9d 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -97,10 +97,11 @@ void simgrid::kernel::activity::ExecImpl::post() /* If the host running the synchro failed, notice it. This way, the asking * process can be killed if it runs on that host itself */ state_ = SIMIX_FAILED; - } else if (surf_action_ && surf_action_->get_state() == simgrid::kernel::resource::Action::State::failed) { + } else if (surf_action_ && surf_action_->get_state() == simgrid::kernel::resource::Action::State::FAILED) { /* If the host running the synchro didn't fail, then the synchro was canceled */ state_ = SIMIX_CANCELED; - } else if (timeout_detector_ && timeout_detector_->get_state() == simgrid::kernel::resource::Action::State::done) { + } else if (timeout_detector_ && + timeout_detector_->get_state() == simgrid::kernel::resource::Action::State::FINISHED) { state_ = SIMIX_TIMEOUT; } else { state_ = SIMIX_DONE; diff --git a/src/kernel/activity/SleepImpl.cpp b/src/kernel/activity/SleepImpl.cpp index 05e8303529..9fa18415ff 100644 --- a/src/kernel/activity/SleepImpl.cpp +++ b/src/kernel/activity/SleepImpl.cpp @@ -33,12 +33,12 @@ void simgrid::kernel::activity::SleepImpl::post() e_smx_state_t result; switch (surf_sleep->get_state()) { - case simgrid::kernel::resource::Action::State::failed: + case simgrid::kernel::resource::Action::State::FAILED: simcall->issuer->context->iwannadie = 1; result = SIMIX_SRC_HOST_FAILURE; break; - case simgrid::kernel::resource::Action::State::done: + case simgrid::kernel::resource::Action::State::FINISHED: result = SIMIX_DONE; break; diff --git a/src/kernel/activity/SynchroIo.cpp b/src/kernel/activity/SynchroIo.cpp index 130354d48e..b1534848d2 100644 --- a/src/kernel/activity/SynchroIo.cpp +++ b/src/kernel/activity/SynchroIo.cpp @@ -35,10 +35,10 @@ void simgrid::kernel::activity::IoImpl::post() } switch (surf_io->get_state()) { - case simgrid::kernel::resource::Action::State::failed: + case simgrid::kernel::resource::Action::State::FAILED: state_ = SIMIX_FAILED; break; - case simgrid::kernel::resource::Action::State::done: + case simgrid::kernel::resource::Action::State::FINISHED: state_ = SIMIX_DONE; break; default: diff --git a/src/kernel/activity/SynchroRaw.cpp b/src/kernel/activity/SynchroRaw.cpp index 69830b02e3..f1fb07fedd 100644 --- a/src/kernel/activity/SynchroRaw.cpp +++ b/src/kernel/activity/SynchroRaw.cpp @@ -27,9 +27,9 @@ void simgrid::kernel::activity::RawImpl::resume() void simgrid::kernel::activity::RawImpl::post() { XBT_IN("(%p)",this); - if (sleep->get_state() == simgrid::kernel::resource::Action::State::failed) + if (sleep->get_state() == simgrid::kernel::resource::Action::State::FAILED) state_ = SIMIX_FAILED; - else if (sleep->get_state() == simgrid::kernel::resource::Action::State::done) + else if (sleep->get_state() == simgrid::kernel::resource::Action::State::FINISHED) state_ = SIMIX_SRC_TIMEOUT; SIMIX_synchro_finish(this); diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index 02505ea100..4fb398fbd8 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -26,7 +26,7 @@ Action::Action(simgrid::kernel::resource::Model* model, double cost, bool failed if (failed) state_set_ = get_model()->get_failed_action_set(); else - state_set_ = get_model()->get_running_action_set(); + state_set_ = get_model()->get_started_action_set(); state_set_->push_back(*this); } @@ -56,31 +56,31 @@ void Action::finish(Action::State state) Action::State Action::get_state() const { if (state_set_ == model_->get_inited_action_set()) - return Action::State::inited; - if (state_set_ == model_->get_running_action_set()) - return Action::State::running; + return Action::State::INITED; + if (state_set_ == model_->get_started_action_set()) + return Action::State::STARTED; if (state_set_ == model_->get_failed_action_set()) - return Action::State::failed; - if (state_set_ == model_->get_done_action_set()) - return Action::State::done; - return Action::State::ignored; + return Action::State::FAILED; + if (state_set_ == model_->get_finished_action_set()) + return Action::State::FINISHED; + return Action::State::IGNORED; } void Action::set_state(Action::State state) { simgrid::xbt::intrusive_erase(*state_set_, *this); switch (state) { - case Action::State::inited: + case Action::State::INITED: state_set_ = model_->get_inited_action_set(); break; - case Action::State::running: - state_set_ = model_->get_running_action_set(); + case Action::State::STARTED: + state_set_ = model_->get_started_action_set(); break; - case Action::State::failed: + case Action::State::FAILED: state_set_ = model_->get_failed_action_set(); break; - case Action::State::done: - state_set_ = model_->get_done_action_set(); + case Action::State::FINISHED: + state_set_ = model_->get_finished_action_set(); break; default: state_set_ = nullptr; @@ -136,7 +136,7 @@ void Action::set_priority(double weight) void Action::cancel() { - set_state(Action::State::failed); + set_state(Action::State::FAILED); if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) { if (modified_set_hook_.is_linked()) simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this); @@ -161,7 +161,7 @@ void Action::suspend() get_model()->get_maxmin_system()->update_variable_weight(get_variable(), 0.0); if (get_model()->get_update_algorithm() == Model::UpdateAlgo::Lazy) { get_model()->get_action_heap().remove(this); - if (state_set_ == get_model()->get_running_action_set() && sharing_priority_ > 0) { + if (state_set_ == get_model()->get_started_action_set() && sharing_priority_ > 0) { // If we have a lazy model, we need to update the remaining value accordingly update_remains_lazy(surf_get_clock()); } diff --git a/src/kernel/resource/Model.cpp b/src/kernel/resource/Model.cpp index f73ee9865e..c8b0e083ca 100644 --- a/src/kernel/resource/Model.cpp +++ b/src/kernel/resource/Model.cpp @@ -17,9 +17,9 @@ Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {} Model::~Model() { delete inited_action_set_; - delete running_action_set_; + delete started_action_set_; delete failed_action_set_; - delete done_action_set_; + delete finished_action_set_; delete maxmin_system_; } @@ -50,7 +50,7 @@ double Model::next_occuring_event_lazy(double now) maxmin_system_->modified_set_->pop_front(); bool max_duration_flag = false; - if (action->get_state_set() != running_action_set_) + if (action->get_state_set() != started_action_set_) continue; /* bogus priority, skip it */ @@ -108,7 +108,7 @@ double Model::next_occuring_event_full(double /*now*/) double min = -1; - for (Action& action : *get_running_action_set()) { + for (Action& action : *get_started_action_set()) { double value = action.get_variable()->get_value(); if (value > 0) { if (action.get_remains() > 0) diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 202aa8f3b8..93196343d6 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -655,7 +655,7 @@ smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, doubl [](void*, void* arg) { auto sleep = static_cast(arg); if (sleep->surf_sleep) - sleep->surf_sleep->finish(simgrid::kernel::resource::Action::State::done); + sleep->surf_sleep->finish(simgrid::kernel::resource::Action::State::FINISHED); intrusive_ptr_release(sleep); return 0; }, diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 649154b07a..6a599e8f5e 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -466,7 +466,7 @@ static inline void SIMIX_comm_start(simgrid::kernel::activity::CommImplPtr comm) receiver->get_cname(), comm->surfAction_); /* If a link is failed, detect it immediately */ - if (comm->surfAction_->get_state() == simgrid::kernel::resource::Action::State::failed) { + if (comm->surfAction_->get_state() == simgrid::kernel::resource::Action::State::FAILED) { XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", sender->get_cname(), receiver->get_cname()); comm->state_ = SIMIX_LINK_FAILURE; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index e01b903371..926ff85060 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -151,11 +151,11 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value) while ((var = cnst->get_variable(&elem))) { kernel::resource::Action* action = static_cast(var->get_id()); - if (action->get_state() == kernel::resource::Action::State::inited || - action->get_state() == kernel::resource::Action::State::running || - action->get_state() == kernel::resource::Action::State::ignored) { + if (action->get_state() == kernel::resource::Action::State::INITED || + action->get_state() == kernel::resource::Action::State::STARTED || + action->get_state() == kernel::resource::Action::State::IGNORED) { action->set_finish_time(date); - action->set_state(kernel::resource::Action::State::failed); + action->set_state(kernel::resource::Action::State::FAILED); } } } diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 05fbd12bf9..7cd104de73 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -28,14 +28,14 @@ void CpuModel::update_actions_state_lazy(double now, double /*delta*/) CpuAction* action = static_cast(get_action_heap().pop()); XBT_CDEBUG(surf_kernel, "Something happened to action %p", action); - action->finish(kernel::resource::Action::State::done); + action->finish(kernel::resource::Action::State::FINISHED); XBT_CDEBUG(surf_kernel, "Action %p finished", action); } if (TRACE_is_enabled()) { //defining the last timestamp that we can safely dump to trace file //without losing the event ascending order (considering all CPU's) double smaller = -1; - for (kernel::resource::Action const& action : *get_running_action_set()) { + for (kernel::resource::Action const& action : *get_started_action_set()) { if (smaller < 0 || action.get_last_update() < smaller) smaller = action.get_last_update(); } @@ -47,7 +47,7 @@ void CpuModel::update_actions_state_lazy(double now, double /*delta*/) void CpuModel::update_actions_state_full(double now, double delta) { - for (auto it = std::begin(*get_running_action_set()); it != std::end(*get_running_action_set());) { + for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { CpuAction& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it @@ -58,7 +58,7 @@ void CpuModel::update_actions_state_full(double now, double delta) if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_weight() > 0)) || ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(kernel::resource::Action::State::done); + action.finish(kernel::resource::Action::State::FINISHED); } } } @@ -161,7 +161,7 @@ void Cpu::set_speed_trace(tmgr_trace_t trace) void CpuAction::update_remains_lazy(double now) { - xbt_assert(get_state_set() == get_model()->get_running_action_set(), + xbt_assert(get_state_set() == get_model()->get_started_action_set(), "You're updating an action that is not running."); xbt_assert(get_priority() > 0, "You're updating an action that seems suspended."); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index b1928e4684..6ce941766b 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -343,7 +343,7 @@ void CpuTiModel::update_actions_state(double now, double /*delta*/) while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) { CpuTiAction* action = static_cast(get_action_heap().pop()); XBT_DEBUG("Action %p: finish", action); - action->finish(kernel::resource::Action::State::done); + action->finish(kernel::resource::Action::State::FINISHED); /* update remaining amount of all actions */ action->cpu_->update_remaining_amount(surf_get_clock()); } @@ -413,11 +413,11 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value) /* put all action running on cpu to failed */ for (CpuTiAction& action : action_set_) { - if (action.get_state() == kernel::resource::Action::State::inited || - action.get_state() == kernel::resource::Action::State::running || - action.get_state() == kernel::resource::Action::State::ignored) { + if (action.get_state() == kernel::resource::Action::State::INITED || + action.get_state() == kernel::resource::Action::State::STARTED || + action.get_state() == kernel::resource::Action::State::IGNORED) { action.set_finish_time(date); - action.set_state(kernel::resource::Action::State::failed); + action.set_state(kernel::resource::Action::State::FAILED); get_model()->get_action_heap().remove(&action); } } @@ -439,7 +439,7 @@ void CpuTi::update_actions_finish_time(double now) sum_priority_ = 0.0; for (CpuTiAction const& action : action_set_) { /* action not running, skip it */ - if (action.get_state_set() != surf_cpu_model_pm->get_running_action_set()) + if (action.get_state_set() != surf_cpu_model_pm->get_started_action_set()) continue; /* bogus priority, skip it */ @@ -456,7 +456,7 @@ void CpuTi::update_actions_finish_time(double now) for (CpuTiAction& action : action_set_) { double min_finish = -1; /* action not running, skip it */ - if (action.get_state_set() != surf_cpu_model_pm->get_running_action_set()) + if (action.get_state_set() != surf_cpu_model_pm->get_started_action_set()) continue; /* verify if the action is really running on cpu */ @@ -513,7 +513,7 @@ void CpuTi::update_remaining_amount(double now) XBT_DEBUG("Flops total: %f, Last update %f", area_total, last_update_); for (CpuTiAction& action : action_set_) { /* action not running, skip it */ - if (action.get_state_set() != get_model()->get_running_action_set()) + if (action.get_state_set() != get_model()->get_started_action_set()) continue; /* bogus priority, skip it */ @@ -613,7 +613,7 @@ void CpuTiAction::set_state(Action::State state) void CpuTiAction::cancel() { - this->set_state(Action::State::failed); + this->set_state(Action::State::FAILED); get_model()->get_action_heap().remove(this); cpu_->set_modified(true); } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 761f90d0bf..2eed509631 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -174,7 +174,7 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/) // no need to communicate anymore // assume that flows that reached max_duration have remaining of 0 XBT_DEBUG("Action %p finished", action); - action->finish(Action::State::done); + action->finish(Action::State::FINISHED); get_action_heap().remove(action); } } @@ -182,7 +182,7 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/) void NetworkCm02Model::update_actions_state_full(double now, double delta) { - for (auto it = std::begin(*get_running_action_set()); it != std::end(*get_running_action_set());) { + for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { NetworkCm02Action& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it XBT_DEBUG("Something happened to action %p", &action); @@ -212,7 +212,7 @@ void NetworkCm02Model::update_actions_state_full(double now, double delta) if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) || ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(Action::State::done); + action.finish(Action::State::FINISHED); } } } @@ -349,9 +349,9 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value) while ((var = get_constraint()->get_variable(&elem))) { Action* action = static_cast(var->get_id()); - if (action->get_state() == Action::State::inited || action->get_state() == Action::State::running) { + if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) { action->set_finish_time(now); - action->set_state(Action::State::failed); + action->set_state(Action::State::FAILED); } } } @@ -448,7 +448,7 @@ void NetworkCm02Action::update_remains_lazy(double now) if ((get_remains_no_update() <= 0 && (get_variable()->get_weight() > 0)) || ((max_duration > NO_MAX_DURATION) && (max_duration <= 0))) { - finish(Action::State::done); + finish(Action::State::FINISHED); get_model()->get_action_heap().remove(this); } diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 197285b6e0..c1f0970c0c 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -35,7 +35,7 @@ LinkImpl* NetworkConstantModel::createLink(const std::string& name, double bw, d double NetworkConstantModel::next_occuring_event(double /*now*/) { double min = -1.0; - for (kernel::resource::Action const& action : *get_running_action_set()) { + for (kernel::resource::Action const& action : *get_started_action_set()) { const NetworkConstantAction& net_action = static_cast(action); if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) min = net_action.latency_; @@ -45,7 +45,7 @@ double NetworkConstantModel::next_occuring_event(double /*now*/) void NetworkConstantModel::update_actions_state(double /*now*/, double delta) { - for (auto it = std::begin(*get_running_action_set()); it != std::end(*get_running_action_set());) { + for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { NetworkConstantAction& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it if (action.latency_ > 0) { @@ -61,7 +61,7 @@ void NetworkConstantModel::update_actions_state(double /*now*/, double delta) if ((action.get_remains_no_update() <= 0) || ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(kernel::resource::Action::State::done); + action.finish(kernel::resource::Action::State::FINISHED); } } } @@ -82,7 +82,7 @@ NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, doubl { latency_ = latency; if (latency_ <= 0.0) - NetworkConstantAction::set_state(Action::State::done); + NetworkConstantAction::set_state(Action::State::FINISHED); }; NetworkConstantAction::~NetworkConstantAction() = default; diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index bc08cedab4..a6335848b3 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -32,7 +32,7 @@ static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkA using simgrid::kernel::resource::IBNode; using simgrid::kernel::resource::NetworkIBModel; - if (action->get_state() != simgrid::kernel::resource::Action::State::done) + if (action->get_state() != simgrid::kernel::resource::Action::State::FINISHED) return; std::pair pair = ((NetworkIBModel*)surf_network_model)->active_comms[action]; XBT_DEBUG("IB callback - action %p finished", action); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index c57f111915..d462377dc3 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -102,7 +102,7 @@ double NetworkModel::next_occuring_event_full(double now) { double minRes = Model::next_occuring_event_full(now); - for (Action const& action : *get_running_action_set()) { + for (Action const& action : *get_started_action_set()) { const NetworkAction& net_action = static_cast(action); if (net_action.latency_ > 0) minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_); diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index ce784077b9..820493bccf 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -190,7 +190,7 @@ double NetworkNS3Model::next_occuring_event(double now) XBT_DEBUG("ns3_next_occuring_event"); //get the first relevant value from the running_actions list - if (not get_running_action_set()->size() || now == 0.0) + if (not get_started_action_set()->size() || now == 0.0) return -1.0; else do { @@ -211,7 +211,7 @@ void NetworkNS3Model::update_actions_state(double now, double delta) static std::vector socket_to_destroy; /* If there are no running flows, advance the NS3 simulator and return */ - if (get_running_action_set()->empty()) { + if (get_started_action_set()->empty()) { while(double_positive(now - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)) ns3_simulator(now-ns3::Simulator::Now().GetSeconds()); @@ -227,7 +227,7 @@ void NetworkNS3Model::update_actions_state(double now, double delta) XBT_DEBUG("Processing socket %p (action %p)",sgFlow,action); action->set_remains(action->get_cost() - sgFlow->sentBytes_); - if (TRACE_is_enabled() && action->get_state() == kernel::resource::Action::State::running) { + if (TRACE_is_enabled() && action->get_state() == kernel::resource::Action::State::STARTED) { double data_delta_sent = sgFlow->sentBytes_ - action->lastSent_; std::vector route = std::vector(); @@ -243,7 +243,7 @@ void NetworkNS3Model::update_actions_state(double now, double delta) if(sgFlow->finished_){ socket_to_destroy.push_back(ns3Socket); XBT_DEBUG("Destroy socket %p of action %p", ns3Socket.c_str(), action); - action->finish(kernel::resource::Action::State::done); + action->finish(kernel::resource::Action::State::FINISHED); } else { XBT_DEBUG("Socket %p sent %u bytes out of %u (%u remaining)", ns3Socket.c_str(), sgFlow->sentBytes_, sgFlow->totalBytes_, sgFlow->remaining_); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 2a2b54afa6..d1485bfb1a 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -68,7 +68,7 @@ NetworkL07Model::~NetworkL07Model() double HostL07Model::next_occuring_event(double now) { double min = HostModel::next_occuring_event_full(now); - for (kernel::resource::Action const& action : *get_running_action_set()) { + for (kernel::resource::Action const& action : *get_started_action_set()) { const L07Action& net_action = static_cast(action); if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) { min = net_action.latency_; @@ -82,7 +82,7 @@ double HostL07Model::next_occuring_event(double now) void HostL07Model::update_actions_state(double /*now*/, double delta) { - for (auto it = std::begin(*get_running_action_set()); it != std::end(*get_running_action_set());) { + for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { L07Action& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it if (action.latency_ > 0) { @@ -114,7 +114,7 @@ void HostL07Model::update_actions_state(double /*now*/, double delta) if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) || ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(kernel::resource::Action::State::done); + action.finish(kernel::resource::Action::State::FINISHED); } else { /* Need to check that none of the model has failed */ int i = 0; @@ -124,7 +124,7 @@ void HostL07Model::update_actions_state(double /*now*/, double delta) void* constraint_id = cnst->get_id(); if (static_cast(constraint_id)->is_off()) { XBT_DEBUG("Action (%p) Failed!!", &action); - action.finish(kernel::resource::Action::State::failed); + action.finish(kernel::resource::Action::State::FAILED); break; } cnst = action.get_variable()->get_constraint(i); diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index a36ca2e732..c9bcc38cb4 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -68,7 +68,7 @@ double StorageN11Model::next_occuring_event(double now) void StorageN11Model::update_actions_state(double /*now*/, double delta) { - for (auto it = std::begin(*get_running_action_set()); it != std::end(*get_running_action_set());) { + for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { StorageAction& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it action.update_remains(lrint(action.get_variable()->get_value() * delta)); @@ -78,7 +78,7 @@ void StorageN11Model::update_actions_state(double /*now*/, double delta) if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_weight() > 0)) || ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(kernel::resource::Action::State::done); + action.finish(kernel::resource::Action::State::FINISHED); } } } @@ -132,7 +132,7 @@ StorageN11Action::StorageN11Action(kernel::resource::Model* model, double cost, void StorageN11Action::cancel() { - set_state(Action::State::failed); + set_state(Action::State::FAILED); } void StorageN11Action::suspend() diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 32f0c00104..83b24b3dfb 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -161,7 +161,7 @@ static simgrid::kernel::resource::Action* ActionListExtract(simgrid::kernel::res simgrid::kernel::resource::Action* surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model) { - return ActionListExtract(model->get_done_action_set()); + return ActionListExtract(model->get_finished_action_set()); } simgrid::kernel::resource::Action* surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model) @@ -171,7 +171,7 @@ simgrid::kernel::resource::Action* surf_model_extract_failed_action_set(simgrid: int surf_model_running_action_set_size(simgrid::kernel::resource::Model* model) { - return model->get_running_action_set()->size(); + return model->get_started_action_set()->size(); } void surf_cpu_action_set_bound(simgrid::kernel::resource::Action* action, double bound) diff --git a/teshsuite/surf/surf_usage/surf_usage.cpp b/teshsuite/surf/surf_usage/surf_usage.cpp index 6299c7cf99..b483226a97 100644 --- a/teshsuite/surf/surf_usage/surf_usage.cpp +++ b/teshsuite/surf/surf_usage/surf_usage.cpp @@ -16,15 +16,15 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example"); static const char* string_action(simgrid::kernel::resource::Action::State state) { switch (state) { - case simgrid::kernel::resource::Action::State::inited: + case simgrid::kernel::resource::Action::State::INITED: return "SURF_ACTION_INITED"; - case simgrid::kernel::resource::Action::State::running: + case simgrid::kernel::resource::Action::State::STARTED: return "SURF_ACTION_RUNNING"; - case simgrid::kernel::resource::Action::State::failed: + case simgrid::kernel::resource::Action::State::FAILED: return "SURF_ACTION_FAILED"; - case simgrid::kernel::resource::Action::State::done: + case simgrid::kernel::resource::Action::State::FINISHED: return "SURF_ACTION_DONE"; - case simgrid::kernel::resource::Action::State::ignored: + case simgrid::kernel::resource::Action::State::IGNORED: return "SURF_ACTION_IGNORED"; default: return "INVALID STATE"; @@ -76,7 +76,7 @@ int main(int argc, char **argv) action.unref(); } - action_list = surf_cpu_model_pm->get_done_action_set(); + action_list = surf_cpu_model_pm->get_finished_action_set(); while (not action_list->empty()) { simgrid::kernel::resource::Action& action = action_list->front(); XBT_INFO(" CPU Done action"); @@ -92,7 +92,7 @@ int main(int argc, char **argv) action.unref(); } - action_list = surf_network_model->get_done_action_set(); + action_list = surf_network_model->get_finished_action_set(); while (not action_list->empty()) { simgrid::kernel::resource::Action& action = action_list->front(); XBT_INFO(" Network Done action"); @@ -101,7 +101,7 @@ int main(int argc, char **argv) } } while ( - (surf_network_model->get_running_action_set()->size() || surf_cpu_model_pm->get_running_action_set()->size()) && + (surf_network_model->get_started_action_set()->size() || surf_cpu_model_pm->get_started_action_set()->size()) && surf_solve(-1.0) >= 0.0); XBT_DEBUG("Simulation Terminated"); -- 2.30.2