Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow and use method chaining for ExecImpl
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 8 Feb 2019 11:33:51 +0000 (12:33 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 8 Feb 2019 11:33:51 +0000 (12:33 +0100)
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp

index 83f36e8..5da186d 100644 (file)
@@ -39,7 +39,7 @@ ExecImpl::~ExecImpl()
   XBT_DEBUG("Destroy exec %p", this);
 }
 
-void ExecImpl::start(double flops_amount, double priority, double bound)
+ExecImpl* ExecImpl::start(double flops_amount, double priority, double bound)
 {
   if (not MC_is_active() && not MC_record_replay_is_active()) {
     surf_action_ = host_->pimpl_cpu->execution_start(flops_amount);
@@ -51,6 +51,7 @@ void ExecImpl::start(double flops_amount, double priority, double bound)
 
   XBT_DEBUG("Create execute synchro %p: %s", this, name_.c_str());
   ExecImpl::on_creation(this);
+  return this;
 }
 
 void ExecImpl::cancel()
index c70aab5..accc1c5 100644 (file)
@@ -19,7 +19,7 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl {
 public:
   explicit ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector,
                     s4u::Host* host);
-  void start(double flops_amount, double priority, double bound);
+  ExecImpl* start(double flops_amount, double priority, double bound);
   void cancel();
   void post() override;
   double get_remaining();
index fe1c956..79f2016 100644 (file)
@@ -176,9 +176,7 @@ smx_activity_t ActorImpl::suspend(ActorImpl* issuer)
 
     return nullptr;
   } else {
-    activity::ExecImplPtr exec = activity::ExecImplPtr(new activity::ExecImpl("suspend", "", nullptr, this->host_));
-    exec->start(0.0, 1.0, 0.0);
-    return exec;
+    return activity::ExecImplPtr(new activity::ExecImpl("suspend", "", nullptr, this->host_))->start(0.0, 1.0, 0.0);
   }
 }
 
index fadbc64..007f8af 100644 (file)
@@ -397,9 +397,8 @@ smx_activity_t simcall_execution_start(std::string name, std::string category, d
                                        double bound, sg_host_t host)
 {
   return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] {
-    simgrid::kernel::activity::ExecImplPtr exec =
-        simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(name, category, nullptr, host));
-    exec->start(flops_amount, priority, bound);
-    return exec;
+    return simgrid::kernel::activity::ExecImplPtr(
+               new simgrid::kernel::activity::ExecImpl(name, category, nullptr, host))
+        ->start(flops_amount, priority, bound);
   });
 }