Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / examples / cpp / exec-waitany / s4u-exec-waitany.cpp
index 07e6ec2..41ad77d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2022. 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. */
@@ -33,17 +33,17 @@ static void worker(bool with_timeout)
    * terminated.
    */
   while (not pending_executions.empty()) {
-    int pos;
+    ssize_t pos;
     if (with_timeout)
-      pos = simgrid::s4u::Exec::wait_any_for(&pending_executions, 4);
+      pos = simgrid::s4u::Exec::wait_any_for(pending_executions, 4);
     else
-      pos = simgrid::s4u::Exec::wait_any(&pending_executions);
+      pos = simgrid::s4u::Exec::wait_any(pending_executions);
 
     if (pos < 0) {
       XBT_INFO("Do not wait any longer for an activity");
       pending_executions.clear();
     } else {
-      XBT_INFO("Activity '%s' (at position %d) is complete", pending_executions[pos]->get_cname(), pos);
+      XBT_INFO("Activity '%s' (at position %zd) is complete", pending_executions[pos]->get_cname(), pos);
       pending_executions.erase(pending_executions.begin() + pos);
     }
     XBT_INFO("%zu activities remain pending", pending_executions.size());
@@ -54,8 +54,8 @@ int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker, false);
-  simgrid::s4u::Actor::create("worker_timeout", simgrid::s4u::Host::by_name("Tremblay"), worker, true);
+  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker, false);
+  simgrid::s4u::Actor::create("worker_timeout", e.host_by_name("Tremblay"), worker, true);
   e.run();
 
   return 0;