Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / examples / s4u / exec-async / s4u-exec-async.cpp
1 /* Copyright (c) 2007-2018. 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
8 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
9
10 static void test(double computation_amount, double priority)
11 {
12   XBT_INFO("Hello! Execute %g flops with priority %g", computation_amount, priority);
13   simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
14   activity->setPriority(priority);
15   activity->start();
16   activity->wait();
17
18   XBT_INFO("Goodbye now!");
19 }
20
21 int main(int argc, char* argv[])
22 {
23   simgrid::s4u::Engine e(&argc, argv);
24   e.load_platform(argv[1]);
25   simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 1.0);
26   simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 2.0);
27
28   e.run();
29
30   XBT_INFO("Simulation time %g", e.get_clock());
31
32   return 0;
33 }