Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add photovoltaic plugin
[simgrid.git] / examples / cpp / comm-ready / s4u-comm-ready.cpp
index 834c7306a1e05e4ead1e7ace4d8a1a0f503196f4..689729815ec64dacc22a4e79fc1cc3fc24253cb8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2023. 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. */
@@ -30,7 +30,7 @@ static void peer(int my_id, int messages_count, size_t payload_size, int peers_c
 {
   /* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put
    * into it */
-  sg4::Mailbox* my_mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(my_id));
+  sg4::Mailbox* my_mbox = sg4::Mailbox::by_name("peer-" + std::to_string(my_id));
   my_mbox->set_receiver(sg4::Actor::self());
 
   std::vector<sg4::CommPtr> pending_comms;
@@ -39,10 +39,10 @@ static void peer(int my_id, int messages_count, size_t payload_size, int peers_c
   for (int i = 0; i < messages_count; i++) {
     for (int peer_id = 0; peer_id < peers_count; peer_id++) {
       if (peer_id != my_id) {
-        sg4::Mailbox* mbox  = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
-        std::string message = std::string("Message ") + std::to_string(i) + " from peer " + std::to_string(my_id);
+        sg4::Mailbox* mbox  = sg4::Mailbox::by_name("peer-" + std::to_string(peer_id));
+        std::string message = "Message " + std::to_string(i) + " from peer " + std::to_string(my_id);
         auto* payload       = new std::string(message); // copy the data we send:
-        // 'msgName' is not a stable storage location
+        // 'message' is not a stable storage location
         XBT_INFO("Send '%s' to '%s'", message.c_str(), mbox->get_cname());
         /* Create a communication representing the ongoing communication */
         pending_comms.push_back(mbox->put_async(payload, payload_size));
@@ -53,7 +53,7 @@ static void peer(int my_id, int messages_count, size_t payload_size, int peers_c
   /* Start sending messages to let peers know that they should stop */
   for (int peer_id = 0; peer_id < peers_count; peer_id++) {
     if (peer_id != my_id) {
-      sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
+      sg4::Mailbox* mbox = sg4::Mailbox::by_name("peer-" + std::to_string(peer_id));
       auto* payload      = new std::string("finalize"); // Make a copy of the data we will send
       pending_comms.push_back(mbox->put_async(payload, payload_size));
       XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id);