Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Replace redundant type with "auto" (examples/).
[simgrid.git] / examples / s4u / maestro-set / s4u-maestro-set.cpp
index 4157f89..8188c9c 100644 (file)
@@ -40,7 +40,7 @@ static void ensure_other_tid()
 static void sender()
 {
   ensure_root_tid();
-  std::string* payload = new std::string("some message");
+  auto* payload = new std::string("some message");
   simgrid::s4u::Mailbox::by_name("some mailbox")->put((void*)payload, 10e8);
 }
 
@@ -48,7 +48,7 @@ static void receiver()
 {
   ensure_other_tid();
 
-  const std::string* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
+  const auto* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
   XBT_INFO("Task received");
   delete payload;
 }
@@ -65,6 +65,10 @@ int main(int argc, char* argv[])
 {
   root_id = std::this_thread::get_id();
 
+  /* Specify which code should be executed by maestro on another thread, once this current thread is affected to an
+   * actor by the subsequent sg_actor_attach(). This must be done before the creation of the engine. */
+  SIMIX_set_maestro(maestro, NULL);
+
   simgrid::s4u::Engine e(&argc, argv);
 
   if (argc != 2) {
@@ -74,9 +78,6 @@ int main(int argc, char* argv[])
 
   e.load_platform(argv[1]);
 
-  /* Specify which code should be executed by maestro on another thread, once this current thread is affected to an
-   * actor by the subsequent sg_actor_attach() */
-  SIMIX_set_maestro(maestro, NULL);
   /* Become one of the simulated process (must be done after the platform creation, or the host won't exist). */
   sg_actor_attach("sender", nullptr, simgrid::s4u::Host::by_name("Tremblay"), nullptr);