Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rework SleepImpl (and save a cast)
[simgrid.git] / src / kernel / activity / SleepImpl.cpp
index 8735baf..fd85d9d 100644 (file)
@@ -18,16 +18,27 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-SleepImpl::~SleepImpl()
+SleepImplPtr SleepImpl::set_name(const std::string& name)
 {
-  if (surf_action_)
-    surf_action_->unref();
-  XBT_DEBUG("Destroy activity %p", this);
+  ActivityImpl::set_name(name);
+  return this;
+}
+
+SleepImplPtr SleepImpl::set_host(s4u::Host* host)
+{
+  host_ = host;
+  return this;
 }
 
-SleepImpl* SleepImpl::start(double duration)
+SleepImplPtr SleepImpl::set_duration(double duration)
 {
-  surf_action_ = host_->pimpl_cpu->sleep(duration);
+  duration_ = duration;
+  return this;
+}
+
+SleepImpl* SleepImpl::start()
+{
+  surf_action_ = host_->pimpl_cpu->sleep(duration_);
   surf_action_->set_data(this);
   XBT_DEBUG("Create sleep synchronization %p", this);
   return this;
@@ -73,7 +84,6 @@ void SleepImpl::post()
       SIMIX_simcall_answer(simcall);
     }
   }
-
   SIMIX_process_sleep_destroy(this);
 }
 void SleepImpl::finish()