Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to name an Exec
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 20 Jul 2018 18:34:49 +0000 (20:34 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 20 Jul 2018 18:34:49 +0000 (20:34 +0200)
include/simgrid/s4u/Exec.hpp
src/s4u/s4u_Exec.cpp

index afb88e1..6d647ff 100644 (file)
@@ -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
 }
index 52f05cb..d956b76 100644 (file)
@@ -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()
 {