From: Martin Quinson Date: Mon, 26 Mar 2018 16:49:05 +0000 (+0200) Subject: Action::is_suspended() does not need to be virtual (+ more snake_casing) X-Git-Tag: v3.20~627^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/265e908745398dd4e9cc55187aa267650468c57c Action::is_suspended() does not need to be virtual (+ more snake_casing) --- diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index f3fa29799d..7b876d0840 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -29,7 +29,7 @@ class XBT_PUBLIC Action { public: /* Lazy update needs this Set hook to maintain a list of the tracked actions */ boost::intrusive::list_member_hook<> modified_set_hook_; - bool isLinkedModifiedSet() const { return modified_set_hook_.is_linked(); } + bool is_within_modified_set() const { return modified_set_hook_.is_linked(); } typedef boost::intrusive::list< Action, boost::intrusive::member_hook, &Action::modified_set_hook_>> ModifiedSet; @@ -97,7 +97,7 @@ public: /** @brief Get the start time of the current action */ double get_start_time() const { return start_time_; } /** @brief Get the finish time of the current action */ - double getFinishTime() const { return finish_time_; } + double get_finish_time() const { return finish_time_; } /** @brief Get the user data associated to the current action */ void* get_data() const { return data_; } @@ -133,8 +133,7 @@ public: /**@brief Add a reference to the current action (refcounting) */ void ref(); /** @brief Unref that action (and destroy it if refcount reaches 0) - * @return true if the action was destroyed and false if someone still has references on it - */ + * @return true if the action was destroyed and false if someone still has references on it */ int unref(); /** @brief Cancel the current Action if running */ @@ -147,7 +146,7 @@ public: virtual void resume(); /** @brief Returns true if the current action is running */ - virtual bool isSuspended(); + bool is_suspended(); /** @brief Get the maximum duration of the current action */ double get_max_duration() const { return max_duration_; } diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index aace67e8f7..8bd4ecad4b 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -536,7 +536,7 @@ template void System::solve(CnstList& cnst_list) elem.make_active(); simgrid::kernel::resource::Action* action = static_cast(elem.variable->id); - if (modified_set_ && not action->isLinkedModifiedSet()) + if (modified_set_ && not action->is_within_modified_set()) modified_set_->push_back(*action); } } diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index a0ad4e1dc1..3fd917cffe 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -184,7 +184,7 @@ void Action::resume() XBT_OUT(); } -bool Action::isSuspended() +bool Action::is_suspended() { return suspended_ == SuspendStates::suspended; } diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index dcc5b111ec..a6c81da4e3 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -289,7 +289,7 @@ void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state) sd_global->completed_tasks->insert(task); task->start_time = task->surf_action->get_start_time(); if (new_state == SD_DONE){ - task->finish_time = task->surf_action->getFinishTime(); + task->finish_time = task->surf_action->get_finish_time(); #if SIMGRID_HAVE_JEDULE jedule_log_sd_event(task); #endif @@ -848,7 +848,7 @@ double SD_task_get_start_time(SD_task_t task) double SD_task_get_finish_time(SD_task_t task) { if (task->surf_action) /* should never happen as actions are destroyed right after their completion */ - return task->surf_action->getFinishTime(); + return task->surf_action->get_finish_time(); else return task->finish_time; } diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 5f63aa3b91..1fb74c02ff 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -494,10 +494,10 @@ void CpuTi::updateActionsFinishTime(double now) action.set_finish_time(speedIntegratedTrace_->solve(now, total_area)); /* verify which event will happen before (max_duration or finish time) */ if (action.get_max_duration() > NO_MAX_DURATION && - action.get_start_time() + action.get_max_duration() < action.getFinishTime()) + action.get_start_time() + action.get_max_duration() < action.get_finish_time()) min_finish = action.get_start_time() + action.get_max_duration(); else - min_finish = action.getFinishTime(); + min_finish = action.get_finish_time(); } else { /* put the max duration time on heap */ if (action.get_max_duration() > NO_MAX_DURATION) @@ -510,7 +510,7 @@ void CpuTi::updateActionsFinishTime(double now) action.heapRemove(model()->getActionHeap()); XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getCname(), - &action, action.get_start_time(), action.getFinishTime(), action.get_max_duration()); + &action, action.get_start_time(), action.get_finish_time(), action.get_max_duration()); } /* remove from modified cpu */ modified(false); @@ -556,7 +556,7 @@ void CpuTi::updateRemainingAmount(double now) continue; /* skip action that are finishing now */ - if (action.getFinishTime() >= 0 && action.getFinishTime() <= now) + if (action.get_finish_time() >= 0 && action.get_finish_time() <= now) continue; /* update remaining */ @@ -676,10 +676,10 @@ void CpuTiAction::set_max_duration(double duration) Action::set_max_duration(duration); if (duration >= 0) - min_finish = (get_start_time() + get_max_duration()) < getFinishTime() ? (get_start_time() + get_max_duration()) - : getFinishTime(); + min_finish = (get_start_time() + get_max_duration()) < get_finish_time() ? (get_start_time() + get_max_duration()) + : get_finish_time(); else - min_finish = getFinishTime(); + min_finish = get_finish_time(); /* add in action heap */ heapUpdate(get_model()->getActionHeap(), min_finish, Action::Type::NOTSET); diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 6e7e60b3d4..87c29933ef 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -222,7 +222,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) double_update(&deltap, action.latency_, sg_surf_precision); action.latency_ = 0.0; } - if (action.latency_ <= 0.0 && not action.isSuspended()) + if (action.latency_ <= 0.0 && not action.is_suspended()) maxmin_system_->update_variable_weight(action.getVariable(), action.weight_); } if (TRACE_is_enabled()) { @@ -419,7 +419,7 @@ void NetworkCm02Link::setBandwidth(double value) while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) { NetworkCm02Action* action = static_cast(var->get_id()); action->weight_ += delta; - if (not action->isSuspended()) + if (not action->is_suspended()) model()->getMaxminSystem()->update_variable_weight(action->getVariable(), action->weight_); } } @@ -452,7 +452,7 @@ void NetworkCm02Link::setLatency(double value) XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", action->latCurrent_); } } - if (not action->isSuspended()) + if (not action->is_suspended()) model()->getMaxminSystem()->update_variable_weight(action->getVariable(), action->weight_); } } diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index b041a1387b..a11bc1f283 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -344,12 +344,6 @@ void NetworkNS3Action::update_remains_lazy(double /*now*/) THROW_IMPOSSIBLE; } -/* Test whether a flow is suspended */ -bool NetworkNS3Action::isSuspended() -{ - return false; -} - } } diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 15d4f5fccd..a180ed23e8 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -47,7 +47,6 @@ class XBT_PRIVATE NetworkNS3Action : public NetworkAction { public: NetworkNS3Action(kernel::resource::Model* model, double cost, s4u::Host* src, s4u::Host* dst); - bool isSuspended() override; void suspend() override; void resume() override; std::list links() override; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index b6700367cb..9e80916f4f 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -93,7 +93,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) } else { action.latency_ = 0.0; } - if ((action.latency_ <= 0.0) && (action.isSuspended() == 0)) { + if ((action.latency_ <= 0.0) && (action.is_suspended() == 0)) { action.updateBound(); maxmin_system_->update_variable_weight(action.getVariable(), 1.0); } diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 5fb3125cfe..68b0ca302f 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -159,11 +159,6 @@ void StorageN11Action::resume() THROW_UNIMPLEMENTED; } -bool StorageN11Action::isSuspended() -{ - return suspended_ == Action::SuspendStates::suspended; -} - void StorageN11Action::set_max_duration(double /*duration*/) { THROW_UNIMPLEMENTED; diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index 0570669fd6..dfcd33e189 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -57,7 +57,6 @@ public: void suspend() override; void cancel() override; void resume() override; - bool isSuspended() override; void set_max_duration(double duration) override; void set_priority(double priority) override; void update_remains_lazy(double now) override;