Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s4u::Actor: Merge signals on_migration_start/end into on_host_change
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 12 Nov 2019 10:48:38 +0000 (11:48 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 12 Nov 2019 11:26:01 +0000 (12:26 +0100)
ChangeLog
include/simgrid/s4u/Actor.hpp
src/instr/instr_platform.cpp
src/s4u/s4u_Actor.cpp

index 2e47233..0878977 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
 
 SimGrid (3.24.1) NOT RELEASED YET (v3.25 expected December 22. 2029, 04:19 UTC)
 
+S4U:
+- Actor: Merge signals on_migration_start/end into on_host_change
+
 Kernel:
 - In simgrid::kernel::resource::Model, the methods next_occuring_event*() have
   been renamed to fix a spelling error. As usual, the previous definitions are
index d0b6d4c..725c8ec 100644 (file)
@@ -74,10 +74,13 @@ public:
   static xbt::signal<void(Actor const&)> on_sleep;
   /** Signal to others that an actor wakes up for a sleep **/
   static xbt::signal<void(Actor const&)> on_wake_up;
-  /** Signal to others that an actor is going to migrated to another host**/
-  static xbt::signal<void(Actor const&)> on_migration_start;
   /** Signal to others that an actor is has been migrated to another host **/
-  static xbt::signal<void(Actor const&)> on_migration_end;
+  static xbt::signal<void(Actor const&, Host const& previous_location)> on_host_change;
+#ifndef DOXYGEN
+  static xbt::signal<void(Actor const&)> on_migration_start; // XBT_ATTRIB_DEPRECATED_v329
+  static xbt::signal<void(Actor const&)> on_migration_end;   // XBT_ATTRIB_DEPRECATED_v329
+#endif
+
   /** Signal indicating that an actor terminated its code.
    *  The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
    *  If you want to free extra data when the actor's destructor is called, use Actor::on_destruction.
index f72c308..56f4747 100644 (file)
@@ -312,20 +312,16 @@ static void instr_actor_on_creation(simgrid::s4u::Actor const& actor)
   });
 }
 
-static long long int counter = 0;
-
-static void instr_actor_on_migration_start(simgrid::s4u::Actor const& actor)
+static void instr_actor_on_host_change(simgrid::s4u::Actor const& actor,
+                                       simgrid::s4u::Host const& /*previous_location*/)
 {
+  static long long int counter = 0;
   // start link
   container_t container = simgrid::instr::Container::by_name(instr_pid(actor));
   simgrid::instr::Container::get_root()->get_link("ACTOR_LINK")->start_event(container, "M", std::to_string(counter));
 
   // destroy existing container of this process
   container->remove_from_parent();
-}
-
-static void instr_actor_on_migration_end(simgrid::s4u::Actor const& actor)
-{
   // create new container on the new_host location
   simgrid::instr::Container::by_name(actor.get_host()->get_name())->create_child(instr_pid(actor), "ACTOR");
   // end link
@@ -403,8 +399,7 @@ void instr_define_callbacks()
     simgrid::s4u::Comm::on_completion.connect([](simgrid::s4u::Actor const& actor) {
       simgrid::instr::Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event();
     });
-    simgrid::s4u::Actor::on_migration_start.connect(instr_actor_on_migration_start);
-    simgrid::s4u::Actor::on_migration_end.connect(instr_actor_on_migration_end);
+    simgrid::s4u::Actor::on_host_change.connect(instr_actor_on_host_change);
   }
 
   if (TRACE_vm_is_enabled()) {
index 10e2530..7a50472 100644 (file)
@@ -28,8 +28,9 @@ xbt::signal<void(Actor const&)> s4u::Actor::on_suspend;
 xbt::signal<void(Actor const&)> s4u::Actor::on_resume;
 xbt::signal<void(Actor const&)> s4u::Actor::on_sleep;
 xbt::signal<void(Actor const&)> s4u::Actor::on_wake_up;
-xbt::signal<void(Actor const&)> s4u::Actor::on_migration_start;
-xbt::signal<void(Actor const&)> s4u::Actor::on_migration_end;
+xbt::signal<void(Actor const&)> s4u::Actor::on_migration_start; // deprecated
+xbt::signal<void(Actor const&)> s4u::Actor::on_migration_end;   // deprecated
+xbt::signal<void(Actor const&, Host const& previous_location)> s4u::Actor::on_host_change;
 xbt::signal<void(Actor const&)> s4u::Actor::on_termination;
 xbt::signal<void(Actor const&)> s4u::Actor::on_destruction;
 
@@ -127,7 +128,17 @@ void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun) const
 
 void Actor::migrate(Host* new_host)
 {
-  s4u::Actor::on_migration_start(*this);
+  if (s4u::Actor::on_migration_start.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329
+    static bool already_warned = false;
+    if (not already_warned) {
+      XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_start. This will be removed "
+               "in v3.29");
+      already_warned = true;
+    }
+    s4u::Actor::on_migration_start(*this);
+  }
+
+  auto* previous_location = get_host();
 
   kernel::actor::simcall([this, new_host]() {
     if (pimpl_->waiting_synchro != nullptr) {
@@ -141,7 +152,17 @@ void Actor::migrate(Host* new_host)
     this->pimpl_->set_host(new_host);
   });
 
-  s4u::Actor::on_migration_end(*this);
+  if (s4u::Actor::on_migration_end.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329
+    static bool already_warned = false;
+    if (not already_warned) {
+      XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_end. This will be removed in "
+               "v3.29");
+      already_warned = true;
+    }
+    s4u::Actor::on_migration_end(*this);
+  }
+
+  s4u::Actor::on_host_change(*this, *previous_location);
 }
 
 s4u::Host* Actor::get_host() const