Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a add_route with s4u::Link instead of LinkInRoute
[simgrid.git] / examples / cpp / network-nonlinear / s4u-network-nonlinear.cpp
index 9bfce5b..d109be7 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <simgrid/s4u.hpp>
+#include <string>
 
 namespace sg4 = simgrid::s4u;
 
@@ -64,22 +65,22 @@ public:
   void operator()()
   {
     /* Where we store all incoming msgs */
-    std::unordered_map<sg4::CommPtr, std::string**> pending_msgs;
+    std::unordered_map<sg4::CommPtr, std::shared_ptr<std::string*>> pending_msgs;
     sg4::ActivitySet pending_comms;
 
     XBT_INFO("Wait for %d messages asynchronously", messages_count);
     for (int i = 0; i < messages_count; i++) {
-      std::string* msg;
-      auto comm = mbox->get_async<std::string>(&msg);
+      std::shared_ptr<std::string*> msg =std::make_shared<std::string*>();
+      auto comm = mbox->get_async<std::string>(msg.get());
       pending_comms.push(comm);
-      pending_msgs.insert({comm, &msg});
+      pending_msgs.insert({comm, msg});
     }
 
     while (not pending_comms.empty()) {
       auto completed_one = pending_comms.wait_any();
       if (completed_one != nullptr){
         auto comm = boost::dynamic_pointer_cast<sg4::Comm>(completed_one);
-        std::string *msg = std::move(*pending_msgs[comm]);
+        auto msg = *pending_msgs[comm];
         XBT_INFO("I got '%s'.", msg->c_str());
         /* cleanup memory and remove from map */
         delete msg;
@@ -130,8 +131,7 @@ static void load_platform()
   link->set_latency(10e-6)->seal();
 
   /* create routes between nodes */
-  zone->add_route(sender->get_netpoint(), receiver->get_netpoint(), nullptr, nullptr,
-                  {{link, sg4::LinkInRoute::Direction::UP}}, true);
+  zone->add_route(sender, receiver, {link});
   zone->seal();
 
   /* create actors Sender/Receiver */