1 /* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */
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. */
6 #include "simgrid/s4u.hpp"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
10 static void test(double computation_amount, double priority)
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->set_priority(priority);
18 XBT_INFO("Goodbye now!");
21 static void test_cancel(double computation_amount)
23 XBT_INFO("Hello! Execute %g flops, should take 1 second", computation_amount);
24 simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(computation_amount);
25 simgrid::s4u::this_actor::sleep_for(0.5);
26 XBT_INFO("I changed my mind, cancel!");
29 XBT_INFO("Goodbye now!");
32 int main(int argc, char* argv[])
34 simgrid::s4u::Engine e(&argc, argv);
35 e.load_platform(argv[1]);
36 simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 1.0);
37 simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Fafard"), test, 7.6296e+07, 2.0);
38 simgrid::s4u::Actor::create("test_cancel", simgrid::s4u::Host::by_name("Boivin"), test_cancel, 98.095e+07);
42 XBT_INFO("Simulation time %g", e.get_clock());