Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
handle SleepImpl more like other activities
[simgrid.git] / src / simix / ActorImpl.cpp
index cfec902..b01c51a 100644 (file)
@@ -5,6 +5,8 @@
 
 #include "mc/mc.h"
 #include "simgrid/Exception.hpp"
+#include "simgrid/s4u/Actor.hpp"
+#include "simgrid/s4u/Exec.hpp"
 #include "smx_private.hpp"
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
@@ -174,7 +176,7 @@ smx_activity_t ActorImpl::suspend(ActorImpl* issuer)
 
     return nullptr;
   } else {
-    return SIMIX_execution_start("suspend", "", 0.0, 1.0, 0.0, this->host_);
+    return activity::ExecImplPtr(new activity::ExecImpl("suspend", "", nullptr, this->host_))->start(0.0, 1.0, 0.0);
   }
 }
 
@@ -204,13 +206,8 @@ smx_activity_t ActorImpl::sleep(double duration)
     throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
         XBT_THROW_POINT, std::string("Host ") + std::string(host_->get_cname()) + " failed, you cannot sleep there.")));
 
-  simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl();
-  synchro->host                                 = host_;
-  synchro->surf_action_                         = host_->pimpl_cpu->sleep(duration);
-  synchro->surf_action_->set_data(synchro);
-  XBT_DEBUG("Create sleep synchronization %p", synchro);
-
-  return synchro;
+  return simgrid::kernel::activity::SleepImplPtr(new simgrid::kernel::activity::SleepImpl("sleep", host_))
+      ->start(duration);
 }
 
 void ActorImpl::throw_exception(std::exception_ptr e)
@@ -262,6 +259,13 @@ void ActorImpl::throw_exception(std::exception_ptr e)
   waiting_synchro = nullptr;
 }
 
+void ActorImpl::set_host(sg_host_t dest)
+{
+  simgrid::xbt::intrusive_erase(host_->pimpl_->process_list_, *this);
+  host_ = dest;
+  dest->pimpl_->process_list_.push_back(*this);
+}
+
 ActorImplPtr ActorImpl::create(std::string name, simgrid::simix::ActorCode code, void* data, simgrid::s4u::Host* host,
                                std::unordered_map<std::string, std::string>* properties, smx_actor_t parent_actor)
 {
@@ -550,13 +554,6 @@ void SIMIX_process_killall(smx_actor_t issuer)
       SIMIX_process_kill(kv.second, issuer);
 }
 
-void SIMIX_process_change_host(smx_actor_t actor, sg_host_t dest)
-{
-  xbt_assert((actor != nullptr), "Invalid parameters");
-  simgrid::xbt::intrusive_erase(actor->host_->pimpl_->process_list_, *actor);
-  actor->host_ = dest;
-  dest->pimpl_->process_list_.push_back(*actor);
-}
 
 void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t actor)
 {