Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
one more legacy MSG function
[simgrid.git] / src / s4u / s4u_Actor.cpp
index 1267fdb..18339ed 100644 (file)
@@ -18,6 +18,8 @@ namespace s4u {
 simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_creation;
 simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_suspend;
 simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_resume;
+simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_sleep;
+simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_wake_up;
 simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_migration_start;
 simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_migration_end;
 simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_destruction;
@@ -252,8 +254,14 @@ bool is_maestro()
 
 void sleep_for(double duration)
 {
-  if (duration > 0)
+  if (duration > 0) {
+    smx_actor_t actor = SIMIX_process_self();
+    simgrid::s4u::Actor::on_sleep(actor->iface());
+
     simcall_process_sleep(duration);
+
+    simgrid::s4u::Actor::on_wake_up(actor->iface());
+  }
 }
 
 void yield()
@@ -265,7 +273,7 @@ XBT_PUBLIC void sleep_until(double timeout)
 {
   double now = SIMIX_get_clock();
   if (timeout > now)
-    simcall_process_sleep(timeout - now);
+    sleep_for(timeout - now);
 }
 
 void execute(double flops)
@@ -533,6 +541,16 @@ sg_actor_t sg_actor_restart(sg_actor_t actor)
   return actor->restart();
 }
 
+/**
+ * \ingroup m_actor_management
+ * \brief Sets the "auto-restart" flag of the actor.
+ * If the flag is set to 1, the actor will be automatically restarted when its host comes back up.
+ */
+void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart)
+{
+  actor->set_auto_restart(auto_restart);
+}
+
 /** @ingroup m_actor_management
  * @brief This actor will be terminated automatically when the last non-daemon actor finishes
  */