Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / examples / s4u / maestro-set / s4u-maestro-set.cpp
index 18fbaa0..3f5e8d8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,7 +22,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
 
-std::thread::id root_id;
+const std::thread::id root_id = std::this_thread::get_id();
 
 static void ensure_root_tid()
 {
@@ -41,16 +41,15 @@ static void sender()
 {
   ensure_root_tid();
   auto* payload = new std::string("some message");
-  simgrid::s4u::Mailbox::by_name("some mailbox")->put((void*)payload, 10e8);
+  simgrid::s4u::Mailbox::by_name("some mailbox")->put(payload, 10e8);
 }
 
 static void receiver()
 {
   ensure_other_tid();
 
-  const auto* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
+  simgrid::s4u::Mailbox::by_name("some mailbox")->get_unique<std::string>();
   XBT_INFO("Task received");
-  delete payload;
 }
 
 static void maestro(void* /* data */)
@@ -63,8 +62,6 @@ static void maestro(void* /* data */)
 /** Main function */
 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, nullptr);