Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change the prototype of s4u::Comm::wait_any to mimick the C code
[simgrid.git] / teshsuite / s4u / comm-waitany / comm-waitany.cpp
index 72568bc..50303b1 100644 (file)
@@ -29,16 +29,10 @@ static void receiver()
     XBT_INFO("Sleeping for 3 seconds (for the %dth time)...", i + 1);
     simgrid::s4u::this_actor::sleep_for(3.0);
     XBT_INFO("Calling wait_any() for %zu pending comms", pending_comms.size());
-    std::vector<simgrid::s4u::CommPtr>::iterator ret_it =
-        simgrid::s4u::Comm::wait_any(pending_comms.begin(), pending_comms.end());
+    int changed_pos = simgrid::s4u::Comm::wait_any(&pending_comms);
     XBT_INFO("Counting the number of completed comms...");
 
-    int count = 0;
-    for (; ret_it != pending_comms.end(); count++, ret_it++)
-      ;
-
-    XBT_INFO("wait_any() replied that %d comms have completed", count);
-    // xbt_assert(count == 1, "wait_any() replied that %d comms have completed, which is broken!", count);
+    pending_comms.erase(pending_comms.begin() + changed_pos);
   }
 }
 
@@ -65,11 +59,12 @@ int main(int argc, char** argv)
 
   engine->loadPlatform(argv[1]);
   simgrid::s4u::Host** hosts = sg_host_list();
-  simgrid::s4u::Actor::createActor("Receiver", hosts[1], receiver);
-  simgrid::s4u::Actor::createActor("Sender", hosts[2], sender);
+  simgrid::s4u::Actor::createActor("Receiver", hosts[0], receiver);
+  simgrid::s4u::Actor::createActor("Sender", hosts[1], sender);
   xbt_free(hosts);
 
-  simgrid::s4u::Engine::instance()->run();
+  engine->run();
 
+  delete engine;
   return 0;
 }