Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to call s4u::Exec->setHost() after its start, to migrate it
[simgrid.git] / src / s4u / s4u_actor.cpp
index a437de0..850069b 100644 (file)
@@ -76,7 +76,9 @@ void Actor::onExit(int_f_pvoid_pvoid_t fun, void* data)
 
 void Actor::migrate(Host* new_host)
 {
-  simgrid::simix::kernelImmediate([this, new_host]() { pimpl_->new_host = new_host; });
+  simgrid::simix::kernelImmediate([this, new_host]() {
+    pimpl_->new_host = new_host;
+  });
 }
 
 s4u::Host* Actor::getHost()
@@ -198,22 +200,6 @@ Actor* Actor::restart()
   return simgrid::simix::kernelImmediate([this]() { return pimpl_->restart(); });
 }
 
-ExecPtr Actor::exec_init(double flops_amount)
-{
-  ExecPtr res        = ExecPtr(new Exec());
-  res->host_         = this->getHost();
-  res->flops_amount_ = flops_amount;
-  res->setRemains(flops_amount);
-  return res;
-}
-
-ExecPtr Actor::exec_async(double flops)
-{
-  ExecPtr res = exec_init(flops);
-  res->start();
-  return res;
-}
-
 // ***** this_actor *****
 
 namespace this_actor {
@@ -276,6 +262,22 @@ void parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, d
   simcall_execution_wait(s);
 }
 
+ExecPtr exec_init(double flops_amount)
+{
+  ExecPtr res        = ExecPtr(new Exec());
+  res->host_         = getHost();
+  res->flops_amount_ = flops_amount;
+  res->setRemains(flops_amount);
+  return res;
+}
+
+ExecPtr exec_async(double flops)
+{
+  ExecPtr res = exec_init(flops);
+  res->start();
+  return res;
+}
+
 void* recv(MailboxPtr chan) // deprecated
 {
   return chan->get();
@@ -361,8 +363,7 @@ void onExit(int_f_pvoid_pvoid_t fun, void* data)
 
 void migrate(Host* new_host)
 {
-  smx_actor_t process = SIMIX_process_self();
-  simgrid::simix::kernelImmediate([process, new_host] { process->new_host = new_host; });
+  SIMIX_process_self()->iface()->migrate(new_host);
 }
 }
 }