Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify process/actor restart
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 21 Jul 2017 12:57:16 +0000 (14:57 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 21 Jul 2017 12:57:16 +0000 (14:57 +0200)
include/simgrid/s4u/Actor.hpp
src/msg/msg_process.cpp
src/s4u/s4u_actor.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp

index 2560aa9..eef1611 100644 (file)
@@ -269,6 +269,7 @@ public:
   /** Retrieve the property value (or nullptr if not set) */
   const char* getProperty(const char* key);
   void setProperty(const char* key, const char* value);
+  Actor* restart();
 };
 
 /** @ingroup s4u_api
index e1ee3c7..17b20f9 100644 (file)
@@ -471,8 +471,7 @@ XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_re
  * \brief Restarts a process from the beginning.
  */
 XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process) {
-  return simgrid::simix::kernelImmediate(
-      [process]() { return process->getImpl()->restart(process->getImpl())->ciface(); });
+  return process->restart();
 }
 
 /** @ingroup m_process_management
index 01ca722..6b6f2ef 100644 (file)
@@ -184,6 +184,11 @@ void Actor::setProperty(const char* key, const char* value)
   });
 }
 
+Actor* Actor::restart()
+{
+  return simgrid::simix::kernelImmediate([this]() { return pimpl_->restart(); });
+}
+
 // ***** this_actor *****
 
 namespace this_actor {
index a33bfac..25902ce 100644 (file)
@@ -167,7 +167,7 @@ void ActorImpl::daemonize()
   }
 }
 
-ActorImpl* ActorImpl::restart(ActorImpl* issuer)
+simgrid::s4u::Actor* ActorImpl::restart()
 {
   XBT_DEBUG("Restarting process %s on %s", cname(), host->getCname());
 
@@ -183,7 +183,7 @@ ActorImpl* ActorImpl::restart(ActorImpl* issuer)
   arg.auto_restart = auto_restart;
 
   // kill the old process
-  SIMIX_process_kill(this, issuer);
+  SIMIX_process_kill(this, this);
 
   // start the new process
   ActorImpl* actor = simix_global->create_process_function(arg.name.c_str(), std::move(arg.code), arg.data, arg.host,
@@ -193,7 +193,7 @@ ActorImpl* ActorImpl::restart(ActorImpl* issuer)
   if (arg.auto_restart)
     actor->auto_restart = arg.auto_restart;
 
-  return actor;
+  return actor->ciface();
 }
 
 smx_activity_t ActorImpl::suspend(ActorImpl* issuer)
index 6baac2c..952546b 100644 (file)
@@ -106,7 +106,7 @@ public:
   void daemonize();
   bool isDaemon() { return daemon; } /** Whether this actor has been daemonized */
   bool isSuspended() { return suspended; }
-  ActorImpl* restart(ActorImpl* issuer);
+  simgrid::s4u::Actor* restart();
   smx_activity_t suspend(ActorImpl* issuer);
   void resume();
   smx_activity_t sleep(double duration);