Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bases for wait distance guide
[simgrid.git] / examples / c / exec-async / exec-async.c
index c795d9be3f5f2b29527ee203bc04293f1369f6d9..fab0ebc30c23969c356ef7aab302916fb2ebc5ec 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2023. 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. */
@@ -15,9 +15,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(exec_async, "Messages specific for this example");
 
 /* This actor simply waits for its task completion after starting it.
  * That's exactly equivalent to synchronous execution. */
-static void waiter(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+static void waiter(int argc, char* argv[])
 {
-  double computation_amount = sg_host_speed(sg_host_self());
+  double computation_amount = sg_host_get_speed(sg_host_self());
   XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
   sg_exec_t activity = sg_actor_exec_init(computation_amount);
   sg_exec_start(activity);
@@ -27,9 +27,9 @@ static void waiter(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 }
 
 /* This actor tests the ongoing execution until its completion, and don't wait before it's terminated. */
-static void monitor(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+static void monitor(int argc, char* argv[])
 {
-  double computation_amount = sg_host_speed(sg_host_self());
+  double computation_amount = sg_host_get_speed(sg_host_self());
   XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
   sg_exec_t activity = sg_actor_exec_init(computation_amount);
   sg_exec_start(activity);
@@ -44,13 +44,12 @@ static void monitor(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 }
 
 /* This actor cancels the ongoing execution after a while. */
-static void canceller(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+static void canceller(int argc, char* argv[])
 {
-  double computation_amount = sg_host_speed(sg_host_self());
+  double computation_amount = sg_host_get_speed(sg_host_self());
 
   XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
-  sg_exec_t activity = sg_actor_exec_init(computation_amount);
-  sg_exec_start(activity);
+  sg_exec_t activity = sg_actor_exec_async(computation_amount);
   sg_actor_sleep_for(0.5);
   XBT_INFO("I changed my mind, cancel!");
   sg_exec_cancel(activity);