Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
start working on adding dependencies between activities
[simgrid.git] / examples / s4u / exec-dependent / s4u-exec-dependent.cpp
1 /* Copyright (c) 2007-2019. 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 simgrid::s4u::ExecPtr second;
11
12 static void worker()
13 {
14   double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
15
16   simgrid::s4u::ExecPtr first = simgrid::s4u::this_actor::exec_init(computation_amount);
17   second                      = simgrid::s4u::this_actor::exec_init(computation_amount);
18
19   first->add_successor(second.get());
20   first->start();
21   first->wait();
22 }
23
24 static void vetoed_worker()
25 {
26   second->vetoable_start();
27   XBT_INFO("%d %d", (int)second->get_state(), second->has_dependencies());
28   second->wait();
29 }
30
31 int main(int argc, char* argv[])
32 {
33   simgrid::s4u::Engine e(&argc, argv);
34   e.load_platform(argv[1]);
35
36   simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Fafard"), worker);
37   simgrid::s4u::Actor::create("vetoed_worker", simgrid::s4u::Host::by_name("Fafard"), vetoed_worker);
38
39   e.run();
40
41   XBT_INFO("Simulation time %g", e.get_clock());
42
43   return 0;
44 }