Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Introduce on_???_cb functions to shield the signals
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 5 Jan 2022 00:28:52 +0000 (01:28 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 5 Jan 2022 00:42:57 +0000 (01:42 +0100)
47 files changed:
ChangeLog
examples/cpp/actor-exiting/s4u-actor-exiting.cpp
examples/cpp/dag-comm/s4u-dag-comm.cpp
examples/cpp/dag-failure/s4u-dag-failure.cpp
examples/cpp/dag-io/s4u-dag-io.cpp
examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp
examples/cpp/dag-simple/s4u-dag-simple.cpp
examples/cpp/exec-dependent/s4u-exec-dependent.cpp
examples/cpp/platform-failures/s4u-platform-failures.cpp
include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/Disk.hpp
include/simgrid/s4u/Engine.hpp
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/Link.hpp
include/simgrid/s4u/NetZone.hpp
include/simgrid/s4u/VirtualMachine.hpp
src/instr/instr_config.cpp
src/instr/instr_paje_containers.hpp
src/instr/instr_paje_events.hpp
src/instr/instr_paje_types.hpp
src/instr/instr_paje_values.hpp
src/instr/instr_platform.cpp
src/kernel/EngineImpl.cpp
src/kernel/resource/VirtualMachineImpl.cpp
src/kernel/routing/NetZoneImpl.cpp
src/msg/msg_global.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/host_load.cpp
src/plugins/link_energy.cpp
src/plugins/link_energy_wifi.cpp
src/plugins/link_load.cpp
src/plugins/vm/VmLiveMigration.cpp
src/plugins/vm/dirty_page_tracking.cpp
src/smpi/bindings/smpi_f77_comm.cpp
src/smpi/bindings/smpi_mpi.cpp
src/smpi/internals/smpi_global.cpp
src/surf/network_ib.cpp
src/surf/network_ns3.cpp
src/surf/sg_platf.cpp
src/surf/xml/surfxml_parseplatf.cpp
src/surf/xml/surfxml_sax_cb.cpp
teshsuite/s4u/dependencies/dependencies.cpp

index 0106da1..e4e7958 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,13 @@ S4U:
  - New function: Engine::track_vetoed_activities() to interrupt run()
    when an activity fails to start, and to keep track of such activities.
    Please see the corresponding example for more info.
+ - Introduce on_X_cb() functions for all signals, to attach a new
+   callback to the signal X. The signal variables are now hidden and
+   only these functions should be used.
+   Rational: this enables the usual deprecation schema where functions
+   remain for 4 releases when we need to modify the signals, while the
+   current code with the signal variables directly visible prevent any
+   smooth transition.
 
 SMPI:
  - Dynamic costs for MPI operations: New API to allow users to dynamically
index 0b61296..ae5e600 100644 (file)
@@ -77,10 +77,10 @@ int main(int argc, char* argv[])
   e.load_platform(argv[1]); /* - Load the platform description */
 
   /* Register a callback in the Actor::on_termination signal. It will be called for every terminated actors */
-  sg4::Actor::on_termination.connect(
+  sg4::Actor::on_termination_cb(
       [](sg4::Actor const& actor) { XBT_INFO("Actor %s terminates now", actor.get_cname()); });
   /* Register a callback in the Actor::on_destruction signal. It will be called for every destructed actors */
-  sg4::Actor::on_destruction.connect(
+  sg4::Actor::on_destruction_cb(
       [](sg4::Actor const& actor) { XBT_INFO("Actor %s gets destroyed now", actor.get_cname()); });
 
   /* Create some actors */
index 9401b8a..525fb68 100644 (file)
@@ -19,12 +19,12 @@ int main(int argc, char* argv[])
   auto jupiter  = e.host_by_name("Jupiter");
 
   // Display the details on vetoed activities
-  simgrid::s4u::Activity::on_veto.connect([](const simgrid::s4u::Activity& a) {
+  simgrid::s4u::Activity::on_veto_cb([](const simgrid::s4u::Activity& a) {
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", a.get_cname(),
              (a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
   });
 
-  simgrid::s4u::Activity::on_completion.connect([](simgrid::s4u::Activity& activity) {
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity& activity) {
     const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
     if (exec != nullptr)
       XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
index 2c6bd2e..8b04b9d 100644 (file)
@@ -18,7 +18,7 @@ int main(int argc, char** argv)
 
   auto* faulty = e.host_by_name("Faulty Host");
   auto* safe   = e.host_by_name("Safe Host");
-  sg4::Activity::on_completion.connect([](sg4::Activity& activity) {
+  sg4::Activity::on_completion_cb([](sg4::Activity& activity) {
     const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
index 9f1bee8..81e2e91 100644 (file)
@@ -19,12 +19,12 @@ int main(int argc, char* argv[])
   auto carl = e.host_by_name("carl");
 
   // Display the details on vetoed activities
-  simgrid::s4u::Activity::on_veto.connect([](const simgrid::s4u::Activity& a) {
+  simgrid::s4u::Activity::on_veto_cb([](const simgrid::s4u::Activity& a) {
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", a.get_cname(),
              (a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
   });
 
-  simgrid::s4u::Activity::on_completion.connect([](simgrid::s4u::Activity& activity) {
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity& activity) {
     const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
index bdced00..df88874 100644 (file)
@@ -153,7 +153,7 @@ int main(int argc, char** argv)
   std::set<simgrid::s4u::Activity*> vetoed;
   e.track_vetoed_activities(&vetoed);
 
-  simgrid::s4u::Activity::on_completion.connect([](simgrid::s4u::Activity& activity) {
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity& activity) {
     // when an Exec completes, we need to set the potential start time of all its ouput comms
     const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
index f377550..03445a4 100644 (file)
@@ -18,7 +18,7 @@ int main(int argc, char* argv[])
   auto fafard = e.host_by_name("Fafard");
 
   // Display the details on vetoed activities
-  simgrid::s4u::Activity::on_veto.connect([](const simgrid::s4u::Activity& a) {
+  simgrid::s4u::Activity::on_veto_cb([](const simgrid::s4u::Activity& a) {
     const auto& exec = static_cast<const simgrid::s4u::Exec&>(a); // all activities are execs in this example
 
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", exec.get_cname(),
@@ -26,7 +26,7 @@ int main(int argc, char* argv[])
              (exec.is_assigned() ? "assigned" : "NOT assigned"));
   });
 
-  simgrid::s4u::Activity::on_completion.connect([](simgrid::s4u::Activity& activity) {
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity& activity) {
     const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
index ada7e5e..dcff84c 100644 (file)
@@ -54,7 +54,7 @@ int main(int argc, char* argv[])
 
   simgrid::s4u::Actor::create("worker", e.host_by_name("Fafard"), worker);
 
-  simgrid::s4u::Activity::on_veto.connect([&e](simgrid::s4u::Activity& a) {
+  simgrid::s4u::Activity::on_veto_cb([&e](simgrid::s4u::Activity& a) {
     auto& exec = static_cast<simgrid::s4u::Exec&>(a);
 
     // First display the situation
index 675e2f1..0417ef6 100644 (file)
@@ -104,7 +104,7 @@ int main(int argc, char* argv[])
   // This is how to attach a profile to an host that is created from the XML file.
   // This should be done before calling load_platform(), as the on_creation() event is fired when loading the platform.
   // You can never set a new profile to a resource that already have one.
-  sg4::Host::on_creation.connect([](sg4::Host& h) {
+  sg4::Host::on_creation_cb([](sg4::Host& h) {
     if (h.get_name() == "Bourrassa") {
       h.set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("bourassa_profile", "67 0\n70 1\n", 0));
     }
index e5aca02..3235775 100644 (file)
@@ -95,13 +95,17 @@ protected:
 
   static std::set<Activity*>* vetoed_activities_;
 
-public:
-  /*! Signal fired each time that the activity fails to start because of a veto (e.g., unsolved dependency or no
-   * resource assigned) */
+private:
   static xbt::signal<void(Activity&)> on_veto;
-  /*! Signal fired when theactivity completes  (either normally, cancelled or failed) */
   static xbt::signal<void(Activity&)> on_completion;
 
+public:
+  /*! Add a callback fired each time that the activity fails to start because of a veto (e.g., unsolved dependency or no
+   * resource assigned) */
+  static void on_veto_cb(const std::function<void(Activity&)>& cb) { on_veto.connect(cb); }
+  /*! Add a callback fired when theactivity completes (either normally, cancelled or failed) */
+  static void on_completion_cb(const std::function<void(Activity&)> cb) { on_completion.connect(cb); }
+
   void vetoable_start()
   {
     state_ = State::STARTING;
index 935187e..3e1b38c 100644 (file)
@@ -68,32 +68,47 @@ public:
   /** Retrieve a reference to myself */
   static Actor* self();
 
-  /** Fired when a new actor has been created **/
+#ifndef DOXYGEN
   static xbt::signal<void(Actor&)> on_creation;
-  /** Signal to others that an actor has been suspended**/
   static xbt::signal<void(Actor const&)> on_suspend;
-  /** Signal to others that an actor has been resumed **/
   static xbt::signal<void(Actor const&)> on_resume;
-  /** Signal to others that an actor is sleeping **/
   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 has been migrated to another host **/
   static xbt::signal<void(const Actor&, const Host& previous_location)> on_host_change;
+  static xbt::signal<void(Actor const&)> on_termination;
+  static xbt::signal<void(Actor const&)> on_destruction;
+#endif
+
+public:
+  /** Add a callback fired when a new actor has been created **/
+  static void on_creation_cb(const std::function<void(Actor&)>& cb) { on_creation.connect(cb); }
+  /** Add a callback fired when an actor has been suspended**/
+  static void on_suspend_cb(const std::function<void(Actor const&)> cb) { on_suspend.connect(cb); }
+  /** Add a callback fired when an actor has been resumed **/
+  static void on_resume_cb(const std::function<void(Actor const&)>& cb) { on_resume.connect(cb); }
+  /** Add a callback fired when an actor starts sleeping **/
+  static void on_sleep_cb(const std::function<void(Actor const&)>& cb) { on_sleep.connect(cb); }
+  /** Add a callback fired when an actor wakes up from a sleep **/
+  static void on_wake_up_cb(const std::function<void(Actor const&)>& cb) { on_wake_up.connect(cb); }
+  /** Add a callback fired when an actor is has been migrated to another host **/
+  static void on_host_change_cb(const std::function<void(const Actor&, const Host& previous_location)>& cb)
+  {
+    on_host_change.connect(cb);
+  }
 
-  /** Signal indicating that an actor terminated its code.
+  /** Add a callback fired when an actor terminates its code.
    *  @beginrst
    *  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 :cpp:var:`Actor::on_destruction`.
    *  If you want to register to the termination of a given actor, use :cpp:func:`this_actor::on_exit()` instead.
    *  @endrst
    */
-  static xbt::signal<void(Actor const&)> on_termination;
-  /** Signal indicating that an actor is about to disappear (its destructor was called).
+  static void on_termination_cb(const std::function<void(Actor const&)>& cb) { on_termination.connect(cb); }
+  /** Add a callback fired when an actor is about to disappear (its destructor was called).
    *  This signal is fired for any destructed actor, which is mostly useful when designing plugins and extensions.
    *  If you want to react to the end of the actor's code, use Actor::on_termination instead.
    *  If you want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
-  static xbt::signal<void(Actor const&)> on_destruction;
+  static void on_destruction_cb(const std::function<void(Actor const&)>& cb) { on_destruction.connect(cb); }
 
   /** Create an actor from a std::function<void()>.
    *  If the actor is restarted, it gets a fresh copy of the function. */
index bee49b3..68f5a8a 100644 (file)
@@ -63,10 +63,17 @@ public:
    */
   static void sendto(Host* from, Host* to, uint64_t simulated_size_in_bytes);
 
+  static void on_send_cb(const std::function<void(Comm const&)>& cb) { on_send.connect(cb); }
+  static void on_recv_cb(const std::function<void(Comm const&)>& cb) { on_recv.connect(cb); }
+  static void on_start_cb(const std::function<void(Comm const&)>& cb) { on_start.connect(cb); }
+  static void on_completion_cb(const std::function<void(Comm const&)>& cb) { on_completion.connect(cb); }
+#ifndef DOXYGEN
+  /* FIXME signals should be private */
   static xbt::signal<void(Comm const&)> on_send;
   static xbt::signal<void(Comm const&)> on_recv;
   static xbt::signal<void(Comm const&)> on_start;
   static xbt::signal<void(Comm const&)> on_completion;
+#endif
 
   /*! take a vector s4u::CommPtr and return when one of them is finished.
    * The return value is the rank of the first finished CommPtr. */
index 7364763..f6a7ea7 100644 (file)
@@ -126,11 +126,16 @@ public:
   Disk* seal();
 
   /* The signals */
-  /** @brief Callback signal fired when a new Disk is created */
+  /** @brief Add a callback fired when a new Disk is created */
+  static void on_creation_cb(const std::function<void(Disk&)>& cb) { on_creation.connect(cb); }
+  /** @brief Add a callback fired when a Disk is destroyed */
+  static void on_destruction_cb(const std::function<void(Disk const&)>& cb) { on_destruction.connect(cb); }
+  /** @brief Add a callback fired when a Disk's state changes */
+  static void on_state_change_cb(const std::function<void(Disk const&)>& cb) { on_state_change.connect(cb); }
+
+private:
   static xbt::signal<void(Disk&)> on_creation;
-  /** @brief Callback signal fired when a Disk is destroyed */
   static xbt::signal<void(Disk const&)> on_destruction;
-  /** @brief Callback signal fired when a Disk's state changes */
   static xbt::signal<void(Disk const&)> on_state_change;
 };
 
index 7b298a4..db83801 100644 (file)
@@ -195,25 +195,32 @@ public:
   static void set_config(const std::string& name, const std::string& value);
 
   Engine* set_default_comm_data_copy_callback(void (*callback)(kernel::activity::CommImpl*, void*, size_t));
-  /** Callback fired when the platform is created (ie, the xml file parsed),
-   * right before the actual simulation starts. */
-  static xbt::signal<void()> on_platform_created;
 
-  /** Callback fired when the platform is about to be created
+  /** Add a callback fired when the platform is created (ie, the xml file parsed),
+   * right before the actual simulation starts. */
+  static void on_platform_created_cb(const std::function<void()>& cb) { on_platform_created.connect(cb); }
+  /** Add a callback fired when the platform is about to be created
    * (ie, after any configuration change and just before the resource creation) */
-  static xbt::signal<void()> on_platform_creation;
+  static void on_platform_creation_cb(const std::function<void()>& cb) { on_platform_creation.connect(cb); }
+  /** Add a callback fired when the main simulation loop ends, just before the end of Engine::run() */
+  static void on_simulation_end_cb(const std::function<void()>& cb) { on_simulation_end.connect(cb); }
 
-  /** Callback fired when the main simulation loop ends, just before the end of Engine::run() */
-  static xbt::signal<void()> on_simulation_end;
-
-  /** Callback fired when the time jumps into the future */
-  static xbt::signal<void(double)> on_time_advance;
+  /** Add a callback fired when the time jumps into the future */
+  static void on_time_advance_cb(const std::function<void(double)>& cb) { on_time_advance.connect(cb); }
 
-  /** Callback fired when the time cannot advance because of inter-actors deadlock. Note that the on_exit of each actor
-   * is also executed on deadlock. */
-  static xbt::signal<void(void)> on_deadlock;
+  /** Add a callback fired when the time cannot advance because of inter-actors deadlock. Note that the on_exit of each
+   * actor is also executed on deadlock. */
+  static void on_deadlock_cb(const std::function<void(void)>& cb) { on_deadlock.connect(cb); }
 
+#ifndef DOXYGEN
+  /* FIXME signals should be private */
+  static xbt::signal<void()> on_platform_created;
+  static xbt::signal<void()> on_platform_creation;
+#endif
 private:
+  static xbt::signal<void()> on_simulation_end;
+  static xbt::signal<void(double)> on_time_advance;
+  static xbt::signal<void(void)> on_deadlock;
   kernel::EngineImpl* const pimpl;
   static Engine* instance_;
   void initialize(int* argc, char** argv);
index 14c173b..1013fcf 100644 (file)
@@ -42,13 +42,15 @@ protected:
 
   void reset() const;
 
+  static xbt::signal<void(Exec const&)> on_start;
+
 public:
 #ifndef DOXYGEN
   Exec(Exec const&) = delete;
   Exec& operator=(Exec const&) = delete;
 #endif
   /*! Signal fired each time that an execution actually starts (no veto) */
-  static xbt::signal<void(Exec const&)> on_start;
+  static void on_start_cb(const std::function<void(Exec const&)>& cb) { on_start.connect(cb); }
 
   static ExecPtr init();
   Exec* start() override;
index e745232..b59ec85 100644 (file)
@@ -54,18 +54,23 @@ public:
 protected:
   virtual ~Host(); // Call destroy() instead of manually deleting it.
   Host* set_netpoint(kernel::routing::NetPoint* netpoint);
-#endif
 
-public:
-  /** Called on each newly created host */
   static xbt::signal<void(Host&)> on_creation;
-  /** Called when the machine is turned on or off (called AFTER the change) */
+  static xbt::signal<void(Host const&)> on_destruction;
+
+public:
+  static xbt::signal<void(Host const&)> on_speed_change;
   static xbt::signal<void(Host const&)> on_state_change;
-  /** Called when the speed of the machine is changed (called AFTER the change)
+#endif
+  /** Add a callback fired on each newly created host */
+  static void on_creation_cb(const std::function<void(Host&)>& cb) { on_creation.connect(cb); }
+  /** Add a callback fired when the machine is turned on or off (called AFTER the change) */
+  static void on_state_change_cb(const std::function<void(Host const&)>& cb) { on_state_change.connect(cb); }
+  /** Add a callback fired when the speed of the machine is changed (called AFTER the change)
    * (either because of a pstate switch or because of an external load event coming from the profile) */
-  static xbt::signal<void(Host const&)> on_speed_change;
-  /** Called just before destructing a host */
-  static xbt::signal<void(Host const&)> on_destruction;
+  static void on_speed_change_cb(const std::function<void(Host const&)>& cb) { on_speed_change.connect(cb); }
+  /** Add a callback fired just before destructing a host */
+  static void on_destruction_cb(const std::function<void(Host const&)>& cb) { on_destruction.connect(cb); }
 
   virtual void destroy();
 #ifndef DOXYGEN
index 5d89a0b..c473b10 100644 (file)
@@ -40,6 +40,9 @@ protected:
   virtual ~Link() = default;
   // The implementation that never changes
   kernel::resource::LinkImplIntf* const pimpl_;
+#ifndef DOXYGEN
+  friend kernel::resource::NetworkAction; // signal comm_state_changed
+#endif
 
 public:
   enum class SharingPolicy { NONLINEAR = 4, WIFI = 3, SPLITDUPLEX = 2, SHARED = 1, FATPIPE = 0 };
@@ -137,22 +140,32 @@ public:
 
   Link* seal();
 
-  /* The signals */
-  /** @brief Callback signal fired when a new Link is created */
+private:
+#ifndef DOXYGEN
   static xbt::signal<void(Link&)> on_creation;
-
-  /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off) */
   static xbt::signal<void(Link const&)> on_state_change;
-
-  /** @brief Callback signal fired when the bandwidth of a Link changes */
   static xbt::signal<void(Link const&)> on_bandwidth_change;
-
-  /** @brief Callback signal fired when a communication changes it state (ready/done/cancel) */
   static xbt::signal<void(kernel::resource::NetworkAction&, kernel::resource::Action::State)>
       on_communication_state_change;
-
-  /** @brief Callback signal fired when a Link is destroyed */
   static xbt::signal<void(Link const&)> on_destruction;
+#endif
+
+public:
+  /* The signals */
+  /** @brief Add a callback fired when a new Link is created */
+  static void on_creation_cb(const std::function<void(Link&)>& cb) { on_creation.connect(cb); }
+  /** @brief Add a callback fired when the state of a Link changes (when it is turned on or off) */
+  static void on_state_change_cb(const std::function<void(Link const&)>& cb) { on_state_change.connect(cb); }
+  /** @brief Add a callback fired when the bandwidth of a Link changes */
+  static void on_bandwidth_change_cb(const std::function<void(Link const&)>& cb) { on_bandwidth_change.connect(cb); }
+  /** @brief Add a callback fired when a communication changes it state (ready/done/cancel) */
+  static void on_communication_state_change_cb(
+      const std::function<void(kernel::resource::NetworkAction&, kernel::resource::Action::State)>& cb)
+  {
+    on_communication_state_change.connect(cb);
+  }
+  /** @brief Add a callback fired when a Link is destroyed */
+  static void on_destruction_cb(std::function<void(Link const&)> cb) { on_destruction.connect(cb); }
 };
 
 /**
index 6c0f3e7..4d37853 100644 (file)
@@ -116,10 +116,14 @@ public:
                           std::vector<kernel::resource::LinkImpl*> const& link_list)>
       on_route_creation; // XBT_ATTRIB_DEPRECATED_v332 : should not be used by users, used by ns3.. if necessary,
                          // signal shouldn't use LinkImpl*
-#endif
 
+private:
   static xbt::signal<void(NetZone const&)> on_creation;
   static xbt::signal<void(NetZone const&)> on_seal;
+#endif
+public:
+  static void on_creation_cb(const std::function<void(NetZone const&)>& cb) { on_creation.connect(cb); }
+  static void on_seal_cb(const std::function<void(NetZone const&)>& cb) { on_seal.connect(cb); }
 
   /**
    * @brief Create a host
index d1c7a84..1292c46 100644 (file)
@@ -69,15 +69,34 @@ public:
   VirtualMachine* set_bound(double bound);
 
   State get_state() const;
+  static void on_creation_cb(const std::function<void(VirtualMachine&)>& cb) { on_creation.connect(cb); }
+  static void on_start_cb(const std::function<void(VirtualMachine const&)>& cb) { on_start.connect(cb); }
+  static void on_started_cb(const std::function<void(VirtualMachine const&)>& cb) { on_started.connect(cb); }
+  static void on_shutdown_cb(const std::function<void(VirtualMachine const&)>& cb) { on_shutdown.connect(cb); }
+  static void on_suspend_cb(const std::function<void(VirtualMachine const&)>& cb) { on_suspend.connect(cb); }
+  static void on_resume_cb(const std::function<void(VirtualMachine const&)>& cb) { on_resume.connect(cb); }
+  static void on_destruction_cb(const std::function<void(VirtualMachine const&)>& cb) { on_destruction.connect(cb); }
+  static void on_migration_start_cb(const std::function<void(VirtualMachine const&)>& cb)
+  {
+    on_migration_start.connect(cb);
+  }
+  static void on_migration_end_cb(const std::function<void(VirtualMachine const&)>& cb)
+  {
+    on_migration_end.connect(cb);
+  }
+#ifndef DOXYGEN
+  /* FIXME the signals should be private */
+  static xbt::signal<void(VirtualMachine const&)> on_migration_start;
+  static xbt::signal<void(VirtualMachine const&)> on_migration_end;
+  static xbt::signal<void(VirtualMachine const&)> on_destruction;
+#endif
+private:
   static xbt::signal<void(VirtualMachine&)> on_creation;
   static xbt::signal<void(VirtualMachine const&)> on_start;
   static xbt::signal<void(VirtualMachine const&)> on_started;
   static xbt::signal<void(VirtualMachine const&)> on_shutdown;
   static xbt::signal<void(VirtualMachine const&)> on_suspend;
   static xbt::signal<void(VirtualMachine const&)> on_resume;
-  static xbt::signal<void(VirtualMachine const&)> on_migration_start;
-  static xbt::signal<void(VirtualMachine const&)> on_migration_end;
-  static xbt::signal<void(VirtualMachine const&)> on_destruction;
 };
 } // namespace s4u
 } // namespace simgrid
index 16f8b15..9016223 100644 (file)
@@ -384,13 +384,13 @@ static void on_simulation_start()
   XBT_DEBUG("Filename %s is open for writing", filename.c_str());
 
   if (format == "Paje") {
-    Container::on_creation.connect(on_container_creation_paje);
-    Container::on_destruction.connect(on_container_destruction_paje);
-    EntityValue::on_creation.connect(on_entity_value_creation);
-    Type::on_creation.connect(on_type_creation);
-    LinkType::on_creation.connect(on_link_type_creation);
-    PajeEvent::on_creation.connect(on_event_creation);
-    PajeEvent::on_destruction.connect(on_event_destruction);
+    Container::on_creation_cb(on_container_creation_paje);
+    Container::on_destruction_cb(on_container_destruction_paje);
+    EntityValue::on_creation_cb(on_entity_value_creation);
+    Type::on_creation_cb(on_type_creation);
+    LinkType::on_creation_cb(on_link_type_creation);
+    PajeEvent::on_creation_cb(on_event_creation);
+    PajeEvent::on_destruction_cb(on_event_destruction);
 
     paje::dump_generator_version();
 
@@ -404,9 +404,9 @@ static void on_simulation_start()
     paje::dump_header(trace_basic, TRACE_display_sizes());
   } else {
     trace_format = TraceFormat::Ti;
-    Container::on_creation.connect(on_container_creation_ti);
-    Container::on_destruction.connect(on_container_destruction_ti);
-    StateEvent::on_destruction.connect(on_state_event_destruction);
+    Container::on_creation_cb(on_container_creation_ti);
+    Container::on_destruction_cb(on_container_destruction_ti);
+    StateEvent::on_destruction_cb(on_state_event_destruction);
   }
 
   trace_active = true;
@@ -464,10 +464,10 @@ void init()
                             6);
 
   /* Connect Engine callbacks */
-  s4u::Engine::on_platform_creation.connect(on_simulation_start);
-  s4u::Engine::on_time_advance.connect([](double /*time_delta*/) { dump_buffer(false); });
-  s4u::Engine::on_deadlock.connect(on_simulation_end);
-  s4u::Engine::on_simulation_end.connect(on_simulation_end);
+  s4u::Engine::on_platform_creation_cb(on_simulation_start);
+  s4u::Engine::on_time_advance_cb([](double /*time_delta*/) { dump_buffer(false); });
+  s4u::Engine::on_deadlock_cb(on_simulation_end);
+  s4u::Engine::on_simulation_end_cb(on_simulation_end);
 }
 } // namespace instr
 } // namespace simgrid
index 8ce3d7f..c10ab2b 100644 (file)
@@ -30,10 +30,14 @@ class Container {
 protected:
   static void set_root(Container* root) { root_container_ = root; }
 
-public:
+private:
   static xbt::signal<void(Container const&)> on_creation;
   static xbt::signal<void(Container const&)> on_destruction;
 
+public:
+  static void on_creation_cb(const std::function<void(Container const&)>& cb) { on_creation.connect(cb); }
+  static void on_destruction_cb(const std::function<void(Container const&)>& cb) { on_destruction.connect(cb); }
+
   explicit Container(const std::string& name, const std::string& type_name, Container* parent);
   Container(const Container&) = delete;
   Container& operator=(const Container&) = delete;
index 17aab29..10c3b3b 100644 (file)
@@ -46,10 +46,13 @@ inline std::ostream& operator<<(std::ostream& os, PajeEventType event)
 class PajeEvent {
   Container* container_;
   Type* type_;
-public:
   static xbt::signal<void(PajeEvent&)> on_creation;
   static xbt::signal<void(PajeEvent const&)> on_destruction;
 
+public:
+  static void on_creation_cb(const std::function<void(PajeEvent&)>& cb) { on_creation.connect(cb); }
+  static void on_destruction_cb(const std::function<void(PajeEvent const&)>& cb) { on_destruction.connect(cb); }
+
   double timestamp_;
   PajeEventType eventType_;
   std::stringstream stream_;
@@ -83,8 +86,10 @@ class StateEvent : public PajeEvent {
 #endif
   std::unique_ptr<TIData> extra_;
 
-public:
   static xbt::signal<void(StateEvent const&)> on_destruction;
+
+public:
+  static void on_destruction_cb(const std::function<void(StateEvent const&)>& cb) { on_destruction.connect(cb); }
   StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra);
   ~StateEvent() override { on_destruction(*this); }
   bool has_extra() const { return extra_ != nullptr; }
index b30eb76..d09cb2b 100644 (file)
@@ -26,11 +26,16 @@ class Type {
   std::map<std::string, std::unique_ptr<Type>, std::less<>> children_;
   Container* issuer_ = nullptr;
 
+  static xbt::signal<void(Type const&, PajeEventType event_type)> on_creation;
+
 protected:
   Container* get_issuer() const { return issuer_; }
 
 public:
-  static xbt::signal<void(Type const&, PajeEventType event_type)> on_creation;
+  static void on_creation_cb(const std::function<void(Type const&, PajeEventType event_type)>& cb)
+  {
+    on_creation.connect(cb);
+  }
 
   Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color,
        Type* parent);
@@ -94,8 +99,13 @@ public:
 };
 
 class LinkType : public ValueType {
-public:
   static xbt::signal<void(LinkType const&, Type const&, Type const&)> on_creation;
+
+public:
+  static void on_creation_cb(const std::function<void(LinkType const&, Type const&, Type const&)>& cb)
+  {
+    on_creation.connect(cb);
+  }
   LinkType(const std::string& name, const Type* source, const Type* dest, const std::string& alias, Type* parent)
       : ValueType(PajeEventType::DefineLinkType, name, alias, parent)
   {
index ee9d3f9..c679fd5 100644 (file)
@@ -18,8 +18,10 @@ class EntityValue {
   std::string color_;
   Type* parent_;
 
-public:
   static xbt::signal<void(const EntityValue&)> on_creation;
+
+public:
+  static void on_creation_cb(const std::function<void(const EntityValue&)>& cb) { on_creation.connect(cb); }
   explicit EntityValue(const std::string& name, const std::string& color, Type* parent);
 
   long long int get_id() const { return id_; }
index 67cf075..c47e879 100644 (file)
@@ -422,70 +422,70 @@ void define_callbacks()
   // always need the callbacks to zones (we need only the root zone), to create the rootContainer and the rootType
   // properly
   if (TRACE_needs_platform()) {
-    s4u::Engine::on_platform_created.connect(on_platform_created);
-    s4u::Host::on_creation.connect(on_host_creation);
-    s4u::Host::on_speed_change.connect([](s4u::Host const& host) {
+    s4u::Engine::on_platform_created_cb(on_platform_created);
+    s4u::Host::on_creation_cb(on_host_creation);
+    s4u::Host::on_speed_change_cb([](s4u::Host const& host) {
       Container::by_name(host.get_name())
           ->get_variable("speed")
           ->set_event(simgrid_get_clock(), host.get_core_count() * host.get_available_speed());
     });
-    s4u::Link::on_creation.connect(on_link_creation);
-    s4u::Link::on_bandwidth_change.connect([](s4u::Link const& link) {
+    s4u::Link::on_creation_cb(on_link_creation);
+    s4u::Link::on_bandwidth_change_cb([](s4u::Link const& link) {
       Container::by_name(link.get_name())
           ->get_variable("bandwidth")
           ->set_event(simgrid_get_clock(), sg_bandwidth_factor * link.get_bandwidth());
     });
-    s4u::NetZone::on_seal.connect([](s4u::NetZone const& /*netzone*/) { currentContainer.pop_back(); });
+    s4u::NetZone::on_seal_cb([](s4u::NetZone const& /*netzone*/) { currentContainer.pop_back(); });
     kernel::routing::NetPoint::on_creation.connect([](kernel::routing::NetPoint const& netpoint) {
       if (netpoint.is_router())
         new RouterContainer(netpoint.get_name(), currentContainer.back());
     });
   }
 
-  s4u::NetZone::on_creation.connect(on_netzone_creation);
+  s4u::NetZone::on_creation_cb(on_netzone_creation);
 
   kernel::resource::CpuAction::on_state_change.connect(on_action_state_change);
-  s4u::Link::on_communication_state_change.connect(on_action_state_change);
+  s4u::Link::on_communication_state_change_cb(on_action_state_change);
 
   if (TRACE_actor_is_enabled()) {
-    s4u::Actor::on_creation.connect(on_actor_creation);
-    s4u::Actor::on_destruction.connect([](s4u::Actor const& actor) {
+    s4u::Actor::on_creation_cb(on_actor_creation);
+    s4u::Actor::on_destruction_cb([](s4u::Actor const& actor) {
       auto container = Container::by_name_or_null(instr_pid(actor));
       if (container != nullptr)
         container->remove_from_parent();
     });
-    s4u::Actor::on_suspend.connect([](s4u::Actor const& actor) {
+    s4u::Actor::on_suspend_cb([](s4u::Actor const& actor) {
       Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->push_event("suspend");
     });
-    s4u::Actor::on_resume.connect(
+    s4u::Actor::on_resume_cb(
         [](s4u::Actor const& actor) { Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); });
-    s4u::Actor::on_sleep.connect([](s4u::Actor const& actor) {
+    s4u::Actor::on_sleep_cb([](s4u::Actor const& actor) {
       Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->push_event("sleep");
     });
-    s4u::Actor::on_wake_up.connect(
+    s4u::Actor::on_wake_up_cb(
         [](s4u::Actor const& actor) { Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); });
-    s4u::Exec::on_start.connect([](s4u::Exec const&) {
+    s4u::Exec::on_start_cb([](s4u::Exec const&) {
       Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->push_event("execute");
     });
-    s4u::Activity::on_completion.connect([](const s4u::Activity&) {
+    s4u::Activity::on_completion_cb([](const s4u::Activity&) {
       Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->pop_event();
     });
-    s4u::Comm::on_send.connect([](s4u::Comm const&) {
+    s4u::Comm::on_send_cb([](s4u::Comm const&) {
       Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->push_event("send");
     });
-    s4u::Comm::on_recv.connect([](s4u::Comm const&) {
+    s4u::Comm::on_recv_cb([](s4u::Comm const&) {
       Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->push_event("receive");
     });
-    s4u::Actor::on_host_change.connect(on_actor_host_change);
+    s4u::Actor::on_host_change_cb(on_actor_host_change);
   }
 
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) {
-    s4u::Exec::on_start.connect([](s4u::Exec const& exec) {
+    s4u::Exec::on_start_cb([](s4u::Exec const& exec) {
       Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
           ->get_state("MPI_STATE")
           ->push_event("computing", new CpuTIData("compute", exec.get_cost()));
     });
-    s4u::Activity::on_completion.connect([](const s4u::Activity&) {
+    s4u::Activity::on_completion_cb([](const s4u::Activity&) {
       Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
           ->get_state("MPI_STATE")
           ->pop_event();
@@ -493,18 +493,18 @@ void define_callbacks()
   }
 
   if (TRACE_vm_is_enabled()) {
-    s4u::Host::on_creation.connect(on_vm_creation);
-    s4u::VirtualMachine::on_start.connect([](s4u::VirtualMachine const& vm) {
+    s4u::Host::on_creation_cb(on_vm_creation);
+    s4u::VirtualMachine::on_start_cb([](s4u::VirtualMachine const& vm) {
       Container::by_name(vm.get_name())->get_state("VM_STATE")->push_event("start");
     });
-    s4u::VirtualMachine::on_started.connect(
+    s4u::VirtualMachine::on_started_cb(
         [](s4u::VirtualMachine const& vm) { Container::by_name(vm.get_name())->get_state("VM_STATE")->pop_event(); });
-    s4u::VirtualMachine::on_suspend.connect([](s4u::VirtualMachine const& vm) {
+    s4u::VirtualMachine::on_suspend_cb([](s4u::VirtualMachine const& vm) {
       Container::by_name(vm.get_name())->get_state("VM_STATE")->push_event("suspend");
     });
-    s4u::VirtualMachine::on_resume.connect(
+    s4u::VirtualMachine::on_resume_cb(
         [](s4u::VirtualMachine const& vm) { Container::by_name(vm.get_name())->get_state("VM_STATE")->pop_event(); });
-    s4u::Host::on_destruction.connect(
+    s4u::Host::on_destruction_cb(
         [](s4u::Host const& host) { Container::by_name(host.get_name())->remove_from_parent(); });
   }
 }
index 4a38f96..c9f6f41 100644 (file)
@@ -238,7 +238,7 @@ void EngineImpl::initialize(int* argc, char** argv)
 
   /* register a function to be called by SURF after the environment creation */
   sg_platf_init();
-  s4u::Engine::on_platform_created.connect([this]() { this->presolve(); });
+  s4u::Engine::on_platform_created_cb([this]() { this->presolve(); });
 
   if (config::get_value<bool>("debug/clean-atexit"))
     atexit(shutdown);
index a04e7ab..e1ab67e 100644 (file)
@@ -118,9 +118,9 @@ static void remove_active_activity(kernel::activity::ActivityImpl const& act)
 
 VMModel::VMModel(const std::string& name) : HostModel(name)
 {
-  s4u::Host::on_state_change.connect(host_state_change);
-  s4u::Exec::on_start.connect(add_active_exec);
-  s4u::Activity::on_completion.connect(remove_active_exec);
+  s4u::Host::on_state_change_cb(host_state_change);
+  s4u::Exec::on_start_cb(add_active_exec);
+  s4u::Activity::on_completion_cb(remove_active_exec);
   activity::ActivityImpl::on_resumed.connect(add_active_activity);
   activity::ActivityImpl::on_suspended.connect(remove_active_activity);
 }
index 68768af..07cfb6e 100644 (file)
@@ -83,9 +83,9 @@ NetZoneImpl::NetZoneImpl(const std::string& name) : piface_(this), name_(name)
     simgrid::s4u::Engine::on_platform_creation();
 
     /* Initialize the surf models. That must be done after we got all config, and before we need the models.
-     * That is, after the last <config> tag, if any, and before the first of cluster|peer|zone|trace|trace_connect
+     * That is, after the last <config> tag, if any, and before the first of cluster|peer|zone|trace|trace_cb
      *
-     * I'm not sure for <trace> and <trace_connect>, there may be a bug here
+     * I'm not sure for <trace> and <trace_cb>, there may be a bug here
      * (FIXME: check it out by creating a file beginning with one of these tags)
      * but cluster and peer come down to zone creations, so putting this verification here is correct.
      */
index 3e18336..1187d8b 100644 (file)
@@ -41,7 +41,7 @@ void MSG_init_nocheck(int* argc, char** argv)
     msg_global->sent_msg = 0;
     msg_global->task_copy_callback = nullptr;
     msg_global->process_data_cleanup = nullptr;
-    simgrid::s4u::Actor::on_termination.connect([](simgrid::s4u::Actor const& actor) {
+    simgrid::s4u::Actor::on_termination_cb([](simgrid::s4u::Actor const& actor) {
       // free the data if a function was provided
       void* userdata = sg_actor_get_data(&actor);
       if (userdata && msg_global->process_data_cleanup)
index ad88b62..e22e8b0 100644 (file)
@@ -463,15 +463,15 @@ void sg_storage_file_system_init()
 
   if (not FileSystemDiskExt::EXTENSION_ID.valid()) {
     FileSystemDiskExt::EXTENSION_ID = simgrid::s4u::Disk::extension_create<FileSystemDiskExt>();
-    simgrid::s4u::Disk::on_creation.connect(&on_disk_creation);
+    simgrid::s4u::Disk::on_creation_cb(&on_disk_creation);
   }
 
   if (not FileDescriptorHostExt::EXTENSION_ID.valid()) {
     FileDescriptorHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create<FileDescriptorHostExt>();
-    simgrid::s4u::Host::on_creation.connect(&on_host_creation);
+    simgrid::s4u::Host::on_creation_cb(&on_host_creation);
   }
-  simgrid::s4u::Engine::on_platform_created.connect(&on_platform_created);
-  simgrid::s4u::Engine::on_simulation_end.connect(&on_simulation_end);
+  simgrid::s4u::Engine::on_platform_created_cb(&on_platform_created);
+  simgrid::s4u::Engine::on_simulation_end_cb(&on_simulation_end);
 }
 
 sg_file_t sg_file_open(const char* fullpath, void* data)
index ef6f7d4..b0677f6 100644 (file)
@@ -295,11 +295,11 @@ public:
         task_id           = 0;
       }
     });
-    simgrid::s4u::Exec::on_start.connect([this](simgrid::s4u::Exec const& activity) {
+    simgrid::s4u::Exec::on_start_cb([this](simgrid::s4u::Exec const& activity) {
       if (activity.get_host() == get_host())
         pre_task();
     });
-    simgrid::s4u::Activity::on_completion.connect([this](simgrid::s4u::Activity& activity) {
+    simgrid::s4u::Activity::on_completion_cb([this](simgrid::s4u::Activity& activity) {
       const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
       if (exec == nullptr) // Only Execs are concerned here
         return;
@@ -444,5 +444,5 @@ void sg_host_dvfs_plugin_init()
 
   sg_host_load_plugin_init();
 
-  simgrid::s4u::Host::on_creation.connect(&on_host_added);
+  simgrid::s4u::Host::on_creation_cb(&on_host_added);
 }
index 18ed351..3b2b483 100644 (file)
@@ -477,11 +477,11 @@ void sg_host_energy_plugin_init()
 
   HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostEnergy>();
 
-  simgrid::s4u::Host::on_creation.connect(&on_creation);
-  simgrid::s4u::Host::on_state_change.connect(&on_host_change);
-  simgrid::s4u::Host::on_speed_change.connect(&on_host_change);
-  simgrid::s4u::Host::on_destruction.connect(&on_host_destruction);
-  simgrid::s4u::Engine::on_simulation_end.connect(&on_simulation_end);
+  simgrid::s4u::Host::on_creation_cb(&on_creation);
+  simgrid::s4u::Host::on_state_change_cb(&on_host_change);
+  simgrid::s4u::Host::on_speed_change_cb(&on_host_change);
+  simgrid::s4u::Host::on_destruction_cb(&on_host_destruction);
+  simgrid::s4u::Engine::on_simulation_end_cb(&on_simulation_end);
   simgrid::kernel::resource::CpuAction::on_state_change.connect(&on_action_state_change);
   // We may only have one actor on a node. If that actor executes something like
   //   compute -> recv -> compute
@@ -489,7 +489,7 @@ void sg_host_energy_plugin_init()
   // that the next trigger would be the 2nd compute, hence ignoring the idle time
   // during the recv call. By updating at the beginning of a compute, we can
   // fix that. (If the cpu is not idle, this is not required.)
-  simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Exec const& activity) {
+  simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
index 3f95fb4..f2b1457 100644 (file)
@@ -227,13 +227,13 @@ void sg_host_load_plugin_init()
   }
 
   // Make sure that every future host also gets an extension (in case the platform is not loaded yet)
-  simgrid::s4u::Host::on_creation.connect([](simgrid::s4u::Host& host) {
+  simgrid::s4u::Host::on_creation_cb([](simgrid::s4u::Host& host) {
     if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
       return;
     host.extension_set(new HostLoad(&host));
   });
 
-  simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Exec const& activity) {
+  simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
       const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
@@ -249,7 +249,7 @@ void sg_host_load_plugin_init()
       XBT_WARN("HostLoad plugin currently does not support executions on several hosts");
     }
   });
-  simgrid::s4u::Activity::on_completion.connect([](simgrid::s4u::Activity& activity) {
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity& activity) {
     const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
@@ -264,8 +264,8 @@ void sg_host_load_plugin_init()
       XBT_WARN("HostLoad plugin currently does not support executions on several hosts");
     }
   });
-  simgrid::s4u::Host::on_state_change.connect(&on_host_change);
-  simgrid::s4u::Host::on_speed_change.connect(&on_host_change);
+  simgrid::s4u::Host::on_state_change_cb(&on_host_change);
+  simgrid::s4u::Host::on_speed_change_cb(&on_host_change);
 }
 
 /** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount)
index 37366fe..078fd85 100644 (file)
@@ -191,7 +191,7 @@ void sg_link_energy_plugin_init()
 
   xbt_assert(sg_host_count() == 0, "Please call sg_link_energy_plugin_init() before initializing the platform.");
 
-  simgrid::s4u::Link::on_creation.connect([](simgrid::s4u::Link& link) {
+  simgrid::s4u::Link::on_creation_cb([](simgrid::s4u::Link& link) {
     if (link.get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
       XBT_DEBUG("Wired Link created: %s", link.get_cname());
       link.extension_set(new LinkEnergy(&link));
@@ -200,12 +200,12 @@ void sg_link_energy_plugin_init()
     }
   });
 
-  simgrid::s4u::Link::on_state_change.connect([](simgrid::s4u::Link const& link) {
+  simgrid::s4u::Link::on_state_change_cb([](simgrid::s4u::Link const& link) {
     if (link.get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI)
       link.extension<LinkEnergy>()->update();
   });
 
-  simgrid::s4u::Link::on_destruction.connect([](simgrid::s4u::Link const& link) {
+  simgrid::s4u::Link::on_destruction_cb([](simgrid::s4u::Link const& link) {
     if (link.get_name() != "__loopback__" && link.get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI)
       XBT_INFO("Energy consumption of link '%s': %f Joules", link.get_cname(),
                link.extension<LinkEnergy>()->get_consumed_energy());
@@ -214,7 +214,7 @@ void sg_link_energy_plugin_init()
   simgrid::kernel::activity::CommImpl::on_start.connect(&on_communication);
   simgrid::kernel::activity::CommImpl::on_completion.connect(&on_communication);
 
-  simgrid::s4u::Engine::on_simulation_end.connect(&on_simulation_end);
+  simgrid::s4u::Engine::on_simulation_end_cb(&on_simulation_end);
 }
 
 /** @ingroup plugin_link_energy
index eee76c6..bee75ad 100644 (file)
@@ -291,7 +291,7 @@ void sg_wifi_energy_plugin_init()
    * - Link::on_communication_state_change: to account for the energy when communications are updated
    * - CommImpl::on_start and CommImpl::on_completion: to account for the energy during communications
    */
-  simgrid::s4u::Link::on_creation.connect([](simgrid::s4u::Link& link) {
+  simgrid::s4u::Link::on_creation_cb([](simgrid::s4u::Link& link) {
     // verify the link is appropriate to WiFi energy computations
     if (link.get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI) {
       XBT_DEBUG("Wifi Link: %s, initialization of wifi energy plugin", link.get_cname());
@@ -302,7 +302,7 @@ void sg_wifi_energy_plugin_init()
     }
   });
 
-  simgrid::s4u::Link::on_destruction.connect([](simgrid::s4u::Link const& link) {
+  simgrid::s4u::Link::on_destruction_cb([](simgrid::s4u::Link const& link) {
     // output energy values if WiFi link
     if (link.get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI) {
       link.extension<LinkEnergyWifi>()->update_destroy();
@@ -314,16 +314,15 @@ void sg_wifi_energy_plugin_init()
     }
   });
 
-  simgrid::s4u::Link::on_communication_state_change.connect(
-      [](simgrid::kernel::resource::NetworkAction const& action,
-         simgrid::kernel::resource::Action::State /* previous */) {
-        // update WiFi links encountered during the communication
-        for (auto const* link : action.get_links()) {
-          if (link != nullptr && link->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI) {
-            link->get_iface()->extension<LinkEnergyWifi>()->update();
-          }
-        }
-      });
+  simgrid::s4u::Link::on_communication_state_change_cb([](simgrid::kernel::resource::NetworkAction const& action,
+                                                          simgrid::kernel::resource::Action::State /* previous */) {
+    // update WiFi links encountered during the communication
+    for (auto const* link : action.get_links()) {
+      if (link != nullptr && link->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI) {
+        link->get_iface()->extension<LinkEnergyWifi>()->update();
+      }
+    }
+  });
 
   simgrid::kernel::activity::CommImpl::on_start.connect(&on_communication);
   simgrid::kernel::activity::CommImpl::on_completion.connect(&on_communication);
index 5f60b67..69b4397 100644 (file)
@@ -189,7 +189,7 @@ void sg_link_load_plugin_init()
   LinkLoad::EXTENSION_ID = simgrid::s4u::Link::extension_create<LinkLoad>();
 
   // Attach new LinkLoad links created in the future.
-  simgrid::s4u::Link::on_creation.connect([](simgrid::s4u::Link& link) {
+  simgrid::s4u::Link::on_creation_cb([](simgrid::s4u::Link& link) {
     if (link.get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
       XBT_DEBUG("Wired link '%s' created. Attaching a LinkLoad to it.", link.get_cname());
       link.extension_set(new LinkLoad(&link));
@@ -202,24 +202,23 @@ void sg_link_load_plugin_init()
   simgrid::kernel::activity::CommImpl::on_start.connect(&on_communication);
   simgrid::kernel::activity::CommImpl::on_completion.connect(&on_communication);
 
-  simgrid::s4u::Link::on_state_change.connect([](simgrid::s4u::Link const& link) {
+  simgrid::s4u::Link::on_state_change_cb([](simgrid::s4u::Link const& link) {
     if (link.get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
       auto link_load = link.extension<LinkLoad>();
       if (link_load->is_tracked())
         link_load->update();
     }
   });
-  simgrid::s4u::Link::on_communication_state_change.connect(
-      [](simgrid::kernel::resource::NetworkAction const& action,
-         simgrid::kernel::resource::Action::State /* previous */) {
-        for (auto const* link : action.get_links()) {
-          if (link != nullptr && link->get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
-            auto link_load = link->get_iface()->extension<LinkLoad>();
-            if (link_load->is_tracked())
-              link_load->update();
-          }
-        }
-      });
+  simgrid::s4u::Link::on_communication_state_change_cb([](simgrid::kernel::resource::NetworkAction const& action,
+                                                          simgrid::kernel::resource::Action::State /* previous */) {
+    for (auto const* link : action.get_links()) {
+      if (link != nullptr && link->get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
+        auto link_load = link->get_iface()->extension<LinkLoad>();
+        if (link_load->is_tracked())
+          link_load->update();
+      }
+    }
+  });
 }
 
 /**
index 3dce9fb..f4dd674 100644 (file)
@@ -290,7 +290,7 @@ void sg_vm_live_migration_plugin_init()
 {
   sg_vm_dirty_page_tracking_init();
   VmMigrationExt::ensureVmMigrationExtInstalled();
-  simgrid::s4u::VirtualMachine::on_shutdown.connect(&onVirtualMachineShutdown);
+  simgrid::s4u::VirtualMachine::on_shutdown_cb(&onVirtualMachineShutdown);
 }
 
 simgrid::s4u::VirtualMachine* sg_vm_create_migratable(simgrid::s4u::Host* pm, const char* name, int coreAmount,
index ff1f087..f4ba064 100644 (file)
@@ -115,9 +115,9 @@ void sg_vm_dirty_page_tracking_init()
   if (not DirtyPageTrackingExt::EXTENSION_ID.valid()) {
     DirtyPageTrackingExt::EXTENSION_ID =
         simgrid::kernel::resource::VirtualMachineImpl::extension_create<DirtyPageTrackingExt>();
-    simgrid::s4u::VirtualMachine::on_creation.connect(&on_virtual_machine_creation);
-    simgrid::s4u::Exec::on_start.connect(&on_exec_creation);
-    simgrid::s4u::Activity::on_completion.connect(&on_exec_completion);
+    simgrid::s4u::VirtualMachine::on_creation_cb(&on_virtual_machine_creation);
+    simgrid::s4u::Exec::on_start_cb(&on_exec_creation);
+    simgrid::s4u::Activity::on_completion_cb(&on_exec_completion);
   }
 }
 
index 91c80bb..6cd4ef3 100644 (file)
@@ -192,9 +192,10 @@ void mpi_comm_call_errhandler_ (int* comm,int* errorcode, int* ierr){
  *ierr = MPI_Comm_call_errhandler(simgrid::smpi::Comm::f2c(*comm), *errorcode);
 }
 
-void mpi_comm_connect_ ( char *port_name, int* info, int* root, int* comm, int*newcomm, int* ierr){
+void mpi_comm_connect_(char* port_name, int* info, int* root, int* comm, int* newcomm, int* ierr)
+{
   MPI_Comm tmp;
-  *ierr = MPI_Comm_connect( port_name, simgrid::smpi::Info::f2c(*info), *root, simgrid::smpi::Comm::f2c(*comm), &tmp);
+  *ierr = MPI_Comm_connect(port_name, simgrid::smpi::Info::f2c(*info), *root, simgrid::smpi::Comm::f2c(*comm), &tmp);
   if(*ierr == MPI_SUCCESS) {
     *newcomm = tmp->c2f();
   }
index c1072a9..471da2e 100644 (file)
@@ -408,7 +408,9 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Add_error_string,( int errorcode,
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Cart_map,(MPI_Comm comm_old, int ndims, const int* dims, const int* periods, int* newrank) ,(comm_old, ndims, dims, periods, newrank))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Close_port,(const char *port_name),( port_name))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_accept,(const char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm),( port_name, info, root, comm, newcomm))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_connect,(const char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm),( port_name, info, root, comm, newcomm))
+UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_Comm_connect,
+                                (const char* port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm* newcomm),
+                                (port_name, info, root, comm, newcomm))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_get_parent,( MPI_Comm *parent),( parent))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_idup,( MPI_Comm comm, MPI_Comm *newcomm, MPI_Request* request),( comm,  newcomm, request))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_join,( int fd, MPI_Comm *intercomm),( fd, intercomm))
index 2a8d188..84c80df 100644 (file)
@@ -596,11 +596,11 @@ int smpi_main(const char* executable, int argc, char* argv[])
 // Called either directly from the user code, or from the code called by smpirun
 void SMPI_init(){
   smpi_init_options_internal(false);
-  simgrid::s4u::Actor::on_creation.connect([](simgrid::s4u::Actor& actor) {
+  simgrid::s4u::Actor::on_creation_cb([](simgrid::s4u::Actor& actor) {
     if (not actor.is_daemon())
       actor.extension_set<simgrid::smpi::ActorExt>(new simgrid::smpi::ActorExt(&actor));
   });
-  simgrid::s4u::Host::on_creation.connect(
+  simgrid::s4u::Host::on_creation_cb(
       [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); });
   for (auto const& host : simgrid::s4u::Engine::get_instance()->get_all_hosts())
     host->extension_set(new simgrid::smpi::Host(host));
index 1ab07ed..b50b769 100644 (file)
@@ -39,9 +39,9 @@ void surf_network_model_init_IB()
   engine->add_model(net_model);
   engine->get_netzone_root()->set_network_model(net_model);
 
-  simgrid::s4u::Link::on_communication_state_change.connect(NetworkIBModel::IB_action_state_changed_callback);
+  simgrid::s4u::Link::on_communication_state_change_cb(NetworkIBModel::IB_action_state_changed_callback);
   simgrid::kernel::activity::CommImpl::on_start.connect(NetworkIBModel::IB_comm_start_callback);
-  simgrid::s4u::Host::on_creation.connect(NetworkIBModel::IB_create_host_callback);
+  simgrid::s4u::Host::on_creation_cb(NetworkIBModel::IB_create_host_callback);
   simgrid::config::set_default<double>("network/weight-S", 8775);
 }
 
index 82e59a5..2943511 100644 (file)
@@ -333,14 +333,14 @@ NetworkNS3Model::NetworkNS3Model(const std::string& name) : NetworkModel(name)
     XBT_VERB("Declare SimGrid's %s within ns-3", pt.get_cname());
   });
 
-  s4u::Engine::on_platform_created.connect([]() {
+  s4u::Engine::on_platform_created_cb([]() {
     /* Create the ns3 topology based on routing strategy */
     ns3::GlobalRouteManager::BuildGlobalRoutingDatabase();
     ns3::GlobalRouteManager::InitializeRoutes();
   });
   routing::on_cluster_creation.connect(&clusterCreation_cb);
   routing::NetZoneImpl::on_route_creation.connect(&routeCreation_cb);
-  s4u::NetZone::on_seal.connect(&zoneCreation_cb);
+  s4u::NetZone::on_seal_cb(&zoneCreation_cb);
 }
 
 LinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
index dd91fbf..a5a06d0 100644 (file)
@@ -56,7 +56,7 @@ void sg_platf_init()
 void sg_platf_exit()
 {
   simgrid::kernel::routing::on_cluster_creation.disconnect_slots();
-  simgrid::s4u::Engine::on_platform_created.disconnect_slots();
+  // simgrid::s4u::Engine::on_platform_created.disconnect_slots();
 
   surf_parse_lex_destroy();
 }
index eb876f0..a7b5c95 100644 (file)
@@ -34,7 +34,8 @@ XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_link
 void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect)
 {
   surf_parse_assert(traces_set_list.find(trace_connect->trace) != traces_set_list.end(),
-         std::string("Cannot connect trace ")+ trace_connect->trace+ " to "+trace_connect->element+": trace unknown");
+                    std::string("Cannot connect trace ") + trace_connect->trace + " to " + trace_connect->element +
+                        ": trace unknown");
 
   switch (trace_connect->kind) {
     case simgrid::kernel::routing::TraceConnectKind::HOST_AVAIL:
@@ -106,7 +107,8 @@ void parse_platform_file(const std::string& file)
 
   /* connect all profiles relative to hosts */
   for (auto const& elm : trace_connect_list_host_avail) {
-    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"HOST_AVAIL\">: Trace ")+elm.first+" undefined.");
+    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(),
+                      std::string("<trace_connect kind=\"HOST_AVAIL\">: Trace ") + elm.first + " undefined.");
     auto profile = traces_set_list.at(elm.first);
 
     auto host = engine->host_by_name_or_null(elm.second);
@@ -115,7 +117,8 @@ void parse_platform_file(const std::string& file)
   }
 
   for (auto const& elm : trace_connect_list_host_speed) {
-    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"SPEED\">: Trace ")+elm.first+" undefined.");
+    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(),
+                      std::string("<trace_connect kind=\"SPEED\">: Trace ") + elm.first + " undefined.");
     auto profile = traces_set_list.at(elm.first);
 
     auto host = engine->host_by_name_or_null(elm.second);
@@ -124,7 +127,8 @@ void parse_platform_file(const std::string& file)
   }
 
   for (auto const& elm : trace_connect_list_link_avail) {
-    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LINK_AVAIL\">: Trace ")+elm.first+" undefined.");
+    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(),
+                      std::string("<trace_connect kind=\"LINK_AVAIL\">: Trace ") + elm.first + " undefined.");
     auto profile = traces_set_list.at(elm.first);
 
     auto link = engine->link_by_name_or_null(elm.second);
@@ -133,7 +137,8 @@ void parse_platform_file(const std::string& file)
   }
 
   for (auto const& elm : trace_connect_list_link_bw) {
-    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"BANDWIDTH\">: Trace ")+elm.first+" undefined.");
+    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(),
+                      std::string("<trace_connect kind=\"BANDWIDTH\">: Trace ") + elm.first + " undefined.");
     auto profile = traces_set_list.at(elm.first);
 
     auto link = engine->link_by_name_or_null(elm.second);
@@ -142,7 +147,8 @@ void parse_platform_file(const std::string& file)
   }
 
   for (auto const& elm : trace_connect_list_link_lat) {
-    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LATENCY\">: Trace ")+elm.first+" undefined.");
+    surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(),
+                      std::string("<trace_connect kind=\"LATENCY\">: Trace ") + elm.first + " undefined.");
     auto profile = traces_set_list.at(elm.first);
 
     auto link = engine->link_by_name_or_null(elm.second);
index 05cff44..aabf032 100644 (file)
@@ -193,17 +193,19 @@ void STag_surfxml_platform() {
       "Use simgrid_update_xml to update your file automatically. "
       "This program is installed automatically with SimGrid, or "
       "available in the tools/ directory of the source archive.");
-  surf_parse_assert((version >= 4.0),
-             std::string("******* THIS FILE IS TOO OLD (v:")+std::to_string(version)+") *********\n "
-             "Changes introduced in SimGrid 3.13:\n"
-             "  - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
-             "  - In <trace_connect>, attribute kind=\"POWER\" is now kind=\"SPEED\".\n"
-             "  - DOCTYPE now point to the rignt URL.\n"
-             "  - speed, bandwidth and latency attributes now MUST have an explicit unit (f, Bps, s by default)"
-             "\n\n"
-             "Use simgrid_update_xml to update your file automatically. "
-             "This program is installed automatically with SimGrid, or "
-             "available in the tools/ directory of the source archive.");
+  surf_parse_assert(
+      (version >= 4.0),
+      std::string("******* THIS FILE IS TOO OLD (v:") + std::to_string(version) +
+          ") *********\n "
+          "Changes introduced in SimGrid 3.13:\n"
+          "  - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
+          "  - In <trace_connect>, attribute kind=\"POWER\" is now kind=\"SPEED\".\n"
+          "  - DOCTYPE now point to the rignt URL.\n"
+          "  - speed, bandwidth and latency attributes now MUST have an explicit unit (f, Bps, s by default)"
+          "\n\n"
+          "Use simgrid_update_xml to update your file automatically. "
+          "This program is installed automatically with SimGrid, or "
+          "available in the tools/ directory of the source archive.");
   if (version < 4.1) {
     XBT_INFO("You're using a v%.1f XML file (%s) while the current standard is v4.1 "
              "That's fine, the new version is backward compatible. \n\n"
@@ -659,27 +661,27 @@ void STag_surfxml_trace___connect()
   simgrid::kernel::routing::TraceConnectCreationArgs trace_connect;
 
   trace_connect.element = A_surfxml_trace___connect_element;
-  trace_connect.trace = A_surfxml_trace___connect_trace;
+  trace_connect.trace   = A_surfxml_trace___connect_trace;
 
   switch (A_surfxml_trace___connect_kind) {
-  case AU_surfxml_trace___connect_kind:
-  case A_surfxml_trace___connect_kind_SPEED:
-    trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::SPEED;
-    break;
-  case A_surfxml_trace___connect_kind_BANDWIDTH:
-    trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::BANDWIDTH;
-    break;
-  case A_surfxml_trace___connect_kind_HOST___AVAIL:
-    trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::HOST_AVAIL;
-    break;
-  case A_surfxml_trace___connect_kind_LATENCY:
-    trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::LATENCY;
-    break;
-  case A_surfxml_trace___connect_kind_LINK___AVAIL:
-    trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::LINK_AVAIL;
-    break;
-  default:
-    surf_parse_error("Invalid trace kind");
+    case AU_surfxml_trace___connect_kind:
+    case A_surfxml_trace___connect_kind_SPEED:
+      trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::SPEED;
+      break;
+    case A_surfxml_trace___connect_kind_BANDWIDTH:
+      trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::BANDWIDTH;
+      break;
+    case A_surfxml_trace___connect_kind_HOST___AVAIL:
+      trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::HOST_AVAIL;
+      break;
+    case A_surfxml_trace___connect_kind_LATENCY:
+      trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::LATENCY;
+      break;
+    case A_surfxml_trace___connect_kind_LINK___AVAIL:
+      trace_connect.kind = simgrid::kernel::routing::TraceConnectKind::LINK_AVAIL;
+      break;
+    default:
+      surf_parse_error("Invalid trace kind");
   }
   sg_platf_trace_connect(&trace_connect);
 }
@@ -808,7 +810,9 @@ void STag_surfxml_model___prop(){
 void ETag_surfxml_prop(){/* Nothing to do */}
 void STag_surfxml_random(){/* Nothing to do */}
 void ETag_surfxml_random(){/* Nothing to do */}
-void ETag_surfxml_trace___connect(){/* Nothing to do */}
+void ETag_surfxml_trace___connect()
+{ /* Nothing to do */
+}
 void STag_surfxml_trace()
 { /* Nothing to do */
 }
index e846943..f0f2ba6 100644 (file)
@@ -13,7 +13,7 @@ int main(int argc, char** argv)
   xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Activity::on_completion.connect([](simgrid::s4u::Activity& activity) {
+  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity& activity) {
     const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;