Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use setters
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 27 Mar 2019 19:11:52 +0000 (20:11 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 27 Mar 2019 19:11:52 +0000 (20:11 +0100)
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/kernel/actor/ActorImpl.cpp
src/s4u/s4u_Exec.cpp
src/simix/libsmx.cpp

index fedef08..844847a 100644 (file)
@@ -51,14 +51,6 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-ExecImpl::ExecImpl(const std::string& name, const std::string& tracing_category) : ActivityImpl(name)
-{
-  this->state_ = SIMIX_RUNNING;
-  this->set_category(tracing_category);
-
-  XBT_DEBUG("Create exec %p", this);
-}
-
 ExecImpl::~ExecImpl()
 {
   if (timeout_detector_)
@@ -72,6 +64,18 @@ ExecImpl* ExecImpl::set_host(s4u::Host* host)
   return this;
 }
 
+ExecImpl* ExecImpl::set_name(const std::string& name)
+{
+  ActivityImpl::set_name(name);
+  return this;
+}
+
+ExecImpl* ExecImpl::set_tracing_category(const std::string& category)
+{
+  ActivityImpl::set_category(category);
+  return this;
+}
+
 ExecImpl* ExecImpl::set_timeout(double timeout)
 {
   if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
@@ -83,6 +87,7 @@ ExecImpl* ExecImpl::set_timeout(double timeout)
 
 ExecImpl* ExecImpl::start(double flops_amount, double priority, double bound)
 {
+  state_ = SIMIX_RUNNING;
   if (not MC_is_active() && not MC_record_replay_is_active()) {
     surf_action_ = host_->pimpl_cpu->execution_start(flops_amount);
     surf_action_->set_data(this);
@@ -99,6 +104,7 @@ ExecImpl* ExecImpl::start(double flops_amount, double priority, double bound)
 ExecImpl* ExecImpl::start(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
                           const std::vector<double>& bytes_amounts)
 {
+  state_ = SIMIX_RUNNING;
   /* set surf's synchro */
   if (not MC_is_active() && not MC_record_replay_is_active()) {
     surf_action_ = surf_host_model->execute_parallel(hosts, flops_amounts.data(), bytes_amounts.data(), -1);
index bf99187..b1dc4f7 100644 (file)
@@ -19,11 +19,12 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl {
   ~ExecImpl();
 
 public:
-  explicit ExecImpl(const std::string& name, const std::string& tracing_category);
   ExecImpl* start(double flops_amount, double priority, double bound);
   ExecImpl* start(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
                   const std::vector<double>& bytes_amounts);
 
+  ExecImpl* set_name(const std::string& name);
+  ExecImpl* set_tracing_category(const std::string& category);
   ExecImpl* set_host(s4u::Host* host);
   ExecImpl* set_timeout(double timeout);
   void cancel();
index 2c3a48a..53caa70 100644 (file)
@@ -371,7 +371,7 @@ activity::ActivityImplPtr ActorImpl::suspend(ActorImpl* issuer)
 
     return nullptr;
   } else {
-    return activity::ExecImplPtr(new activity::ExecImpl("suspend", ""))->set_host(host_)->start(0.0, 1.0, 0.0);
+    return activity::ExecImplPtr(new activity::ExecImpl())->set_name("suspend")->set_host(host_)->start(0.0, 1.0, 0.0);
   }
 }
 
index 75a2162..89f7386 100644 (file)
@@ -17,7 +17,7 @@ xbt::signal<void(Actor const&)> Exec::on_completion;
 
 Exec::Exec()
 {
-  pimpl_ = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl(name_, tracing_category_));
+  pimpl_ = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
 }
 
 bool Exec::test()
@@ -127,7 +127,10 @@ ExecSeq::ExecSeq(sg_host_t host, double flops_amount) : Exec(), flops_amount_(fl
 Exec* ExecSeq::start()
 {
   simix::simcall([this] {
-    boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->start(flops_amount_, 1. / priority_, bound_);
+    boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)
+        ->set_name(name_)
+        ->set_tracing_category(tracing_category_)
+        ->start(flops_amount_, 1. / priority_, bound_);
   });
   state_ = State::STARTED;
   on_start(*Actor::self());
index 4909007..df3df95 100644 (file)
@@ -384,8 +384,9 @@ smx_activity_t simcall_execution_start(const std::string& name, const std::strin
                                        double priority, double bound, sg_host_t host)
 {
   return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] {
-    return simgrid::kernel::activity::ExecImplPtr(
-               new simgrid::kernel::activity::ExecImpl(std::move(name), std::move(category)))
+    return simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl())
+        ->set_name(name)
+        ->set_tracing_category(category)
         ->set_host(host)
         ->start(flops_amount, priority, bound);
   });
@@ -424,7 +425,8 @@ smx_activity_t simcall_execution_parallel_start(const std::string& name, int hos
   if (bytes_amount != nullptr)
     bytes_parallel_amount = std::vector<double>(bytes_amount, bytes_amount + host_nb * host_nb);
   return simgrid::simix::simcall([name, hosts, flops_parallel_amount, bytes_parallel_amount, timeout] {
-    return simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(std::move(name), ""))
+    return simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl())
+        ->set_name(name)
         ->set_timeout(timeout)
         ->start(hosts, flops_parallel_amount, bytes_parallel_amount);
   });