From 4641bc8dbd25bb7399350963514d3531e522e642 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 8 Jul 2018 00:58:53 +0200 Subject: [PATCH] CpuTiTmgr: further cleanups (make the enum class private) --- src/surf/cpu_ti.cpp | 17 +++++++---------- src/surf/cpu_ti.hpp | 5 +++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index bbc2ffa0be..2448cefa3b 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -61,19 +61,18 @@ CpuTiTmgr::~CpuTiTmgr() */ double CpuTiTmgr::integrate(double a, double b) { - int a_index; - if ((a < 0.0) || (a > b)) { xbt_die("Error, invalid integration interval [%.2f,%.2f]. " "You probably have a task executing with negative computation amount. Check your code.", a, b); } - if (fabs(a -b) < EPSILON) + if (fabs(a - b) < EPSILON) return 0.0; if (type_ == Type::FIXED) { - return ((b - a) * value_); + return (b - a) * value_; } + int a_index; if (fabs(ceil(a / last_time_) - a / last_time_) < EPSILON) a_index = 1 + static_cast(ceil(a / last_time_)); else @@ -390,13 +389,12 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value) set_modified(true); - tmgr_trace_t speedTrace = speed_integrated_trace_->speed_trace_; - trace_mgr::DatedValue val = speedTrace->event_list.back(); + trace_mgr::DatedValue val = speed_integrated_trace_->speed_trace_->event_list.back(); delete speed_integrated_trace_; speed_.scale = val.value_; - CpuTiTmgr* trace = new CpuTiTmgr(CpuTiTmgr::Type::FIXED, val.value_); - XBT_DEBUG("value %f", val.value_); + CpuTiTmgr* trace = new CpuTiTmgr(val.value_); + XBT_DEBUG("New fixed value: %f", val.value_); speed_integrated_trace_ = trace; @@ -503,8 +501,7 @@ double CpuTi::get_speed_ratio() /** @brief Update the remaining amount of actions */ void CpuTi::update_remaining_amount(double now) { - - /* already updated */ + /* already up to date */ if (last_update_ >= now) return; diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index df031110a3..3407c0b6a3 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -41,12 +41,13 @@ public: }; class CpuTiTmgr { -public: enum class Type { FIXED, /*< Trace fixed, no availability file */ DYNAMIC /*< Dynamic, have an availability file */ }; - CpuTiTmgr(Type type, double value) : type_(type), value_(value){}; + +public: + CpuTiTmgr(double value) : type_(Type::FIXED), value_(value){}; CpuTiTmgr(tmgr_trace_t speed_trace, double value); CpuTiTmgr(const CpuTiTmgr&) = delete; CpuTiTmgr& operator=(const CpuTiTmgr&) = delete; -- 2.20.1