Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add the exec-async example to the doc
[simgrid.git] / examples / s4u / exec-async / s4u-exec-async.cpp
1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/s4u.hpp"
7 #include "simgrid/forward.h"
8 #include "simgrid/s4u/forward.hpp"
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
11
12 static void test(double computation_amount, double priority)
13 {
14   XBT_INFO("Hello! Execute %g flops with priority %g", computation_amount, priority);
15   simgrid::s4u::ExecPtr activity = simgrid::s4u::Actor::self()->exec_init(computation_amount);
16   activity->setPriority(priority);
17   activity->start();
18   activity->wait();
19
20   XBT_INFO("Goodbye now!");
21 }
22
23 int main(int argc, char* argv[])
24 {
25   simgrid::s4u::Engine e(&argc, argv);
26   e.loadPlatform(argv[1]);
27   simgrid::s4u::Actor::createActor("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 1.0);
28   simgrid::s4u::Actor::createActor("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 2.0);
29
30   e.run();
31
32   XBT_INFO("Simulation time %g", e.getClock());
33
34   return 0;
35 }