Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix ns3
[simgrid.git] / examples / c / async-waitany / async-waitany.c
index cff2764..d5c0644 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(async_waitany, "Messages specific for this example");
 
-static int sender(int argc, char* argv[])
+static void sender(int argc, char* argv[])
 {
   xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
-  long messages_count  = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
-  long msg_size        = xbt_str_parse_int(argv[2], "Invalid communication size: %s");
+  long messages_count  = xbt_str_parse_int(argv[1], "Invalid message count: %s");
+  long msg_size        = xbt_str_parse_int(argv[2], "Invalid message size: %s");
   long receivers_count = xbt_str_parse_int(argv[3], "Invalid amount of receivers: %s");
 
   /* Array in which we store all ongoing communications */
@@ -58,12 +58,12 @@ static int sender(int argc, char* argv[])
 
   /* Now that all message exchanges were initiated, wait for their completion, in order of termination.
    *
-   * This loop waits for first terminating message with wait_any() and remove it with erase(), until all comms are
-   * terminated
+   * This loop waits for first terminating message with wait_any() and remove it from the array (with a memmove),
+   *  until all comms are terminated.
    * Even in this simple example, the pending comms do not terminate in the exact same order of creation.
    */
   while (pending_comms_count != 0) {
-    int changed_pos = sg_comm_wait_any_for(pending_comms, pending_comms_count, -1);
+    int changed_pos = sg_comm_wait_any(pending_comms, pending_comms_count);
     memmove(pending_comms + changed_pos, pending_comms + changed_pos + 1,
             sizeof(sg_comm_t) * (pending_comms_count - changed_pos - 1));
     pending_comms_count--;
@@ -77,10 +77,9 @@ static int sender(int argc, char* argv[])
   free(mboxes);
 
   XBT_INFO("Goodbye now!");
-  return 0;
 }
 
-static int receiver(int argc, char* argv[])
+static void receiver(int argc, char* argv[])
 {
   xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
   int id = xbt_str_parse_int(argv[1], "ID should be numerical, not %s");
@@ -99,7 +98,6 @@ static int receiver(int argc, char* argv[])
   }
 
   XBT_INFO("I'm done. See you!");
-  return 0;
 }
 
 int main(int argc, char* argv[])
@@ -117,7 +115,6 @@ int main(int argc, char* argv[])
   simgrid_load_deployment(argv[2]);
 
   simgrid_run();
-
   XBT_INFO("Simulation time %g", simgrid_get_clock());
 
   return 0;