Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / kernel / activity / SleepImpl.cpp
index edabd24..e8b04dd 100644 (file)
@@ -8,7 +8,6 @@
 #include "simgrid/kernel/resource/Action.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "src/kernel/context/Context.hpp"
-#include "src/simix/ActorImpl.hpp"
 #include "src/simix/popping_private.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/surf/cpu_interface.hpp"
@@ -19,16 +18,21 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-SleepImpl::~SleepImpl()
+SleepImpl& SleepImpl::set_host(s4u::Host* host)
 {
-  if (surf_action_)
-    surf_action_->unref();
-  XBT_DEBUG("Destroy activity %p", this);
+  host_ = host;
+  return *this;
 }
 
-SleepImpl* SleepImpl::start(double duration)
+SleepImpl& 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;
@@ -60,7 +64,6 @@ void SleepImpl::post()
 
       default:
         THROW_IMPOSSIBLE;
-        break;
     }
     if (not simcall->issuer->get_host()->is_on()) {
       simcall->issuer->context_->iwannadie = true;
@@ -75,7 +78,6 @@ void SleepImpl::post()
       SIMIX_simcall_answer(simcall);
     }
   }
-
   SIMIX_process_sleep_destroy(this);
 }
 void SleepImpl::finish()