From 37dcfafac51a942b0219878f2a329b0db83e2ba7 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 20 Jul 2018 20:34:49 +0200 Subject: [PATCH] allow to name an Exec --- include/simgrid/s4u/Exec.hpp | 2 ++ src/s4u/s4u_Exec.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index afb88e1463..6d647ffaad 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -31,6 +31,7 @@ public: ExecPtr set_priority(double priority); ExecPtr set_bound(double bound); ExecPtr set_host(Host* host); + ExecPtr set_name(std::string name); Host* get_host(); double get_remaining() override; @@ -59,6 +60,7 @@ private: double flops_amount_ = 0.0; double priority_ = 1.0; double bound_ = 0.0; + std::string name_ = ""; std::atomic_int_fast32_t refcount_{0}; }; // class } diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 52f05cb60f..d956b76c19 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -15,7 +15,7 @@ namespace s4u { Activity* Exec::start() { - pimpl_ = simcall_execution_start("", flops_amount_, 1. / priority_, bound_, host_); + pimpl_ = simcall_execution_start(name_, flops_amount_, 1. / priority_, bound_, host_); state_ = State::STARTED; return this; } @@ -89,6 +89,13 @@ ExecPtr Exec::set_host(Host* host) return this; } +ExecPtr Exec::set_name(std::string name) +{ + xbt_assert(state_ == State::INITED, "Cannot change the name of an exec after its start"); + name_ = name; + return this; +} + /** @brief Retrieve the host on which this activity takes place. */ Host* Exec::get_host() { -- 2.20.1