]> AND Public Git Repository - simgrid.git/blobdiff - teshsuite/s4u/wait-any-for/wait-any-for.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add memset(0) for shared calloc.
[simgrid.git] / teshsuite / s4u / wait-any-for / wait-any-for.cpp
index 6558a473a430e9af972296921661e88a80385c95..7f40e7f0d63c1338fa42899fba0f56c975c84651 100644 (file)
@@ -8,23 +8,24 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(meh, "meh");
 static void worker()
 {
   auto mbox = simgrid::s4u::Mailbox::by_name("meh");
-  int input_data[2] = {42, 51};
+  int input1 = 42;
+  int input2 = 51;
 
-  XBT_INFO("Sending and receiving %d and %d asynchronously", input_data[0], input_data[1]);
+  XBT_INFO("Sending and receiving %d and %d asynchronously", input1, input2);
 
-  auto put1 = mbox->put_async(input_data, 1000*1000*500);
-  auto put2 = mbox->put_async(input_data + 1, 1000*1000*1000);
+  auto put1 = mbox->put_async(&input1, 1000 * 1000 * 500);
+  auto put2 = mbox->put_async(&input2, 1000 * 1000 * 1000);
 
-  int * out1;
-  auto get1 = mbox->get_async((void**)&out1);
+  int* out1;
+  auto get1 = mbox->get_async<int>(&out1);
 
-  int * out2;
-  auto get2 = mbox->get_async((void**)&out2);
+  int* out2;
+  auto get2 = mbox->get_async<int>(&out2);
 
   XBT_INFO("All comms have started");
   std::vector<simgrid::s4u::CommPtr> comms = {put1, put2, get1, get2};
 
-  while (!comms.empty()) {
+  while (not comms.empty()) {
     int index = simgrid::s4u::Comm::wait_any_for(&comms, 0.5);
     if (index < 0)
       XBT_INFO("wait_any_for: Timeout reached");