Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
improve that example so that it also demonstrates the prioritized executions
[simgrid.git] / examples / s4u / actor-priority / s4u-actor-priority.cpp
1 /* Copyright (c) 2007-2016. 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 <cstdlib>
8 #include <iostream>
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
11
12 class test {
13   double computation_amount;
14   double priority;
15
16 public:
17   explicit test(std::vector<std::string> args)
18 {
19   computation_amount = std::stod(args[1]);
20   priority = std::stod(args[2]);
21 }
22 void operator()()
23 {
24   XBT_INFO("Hello! Running an actor of size %g with priority %g", computation_amount, priority);
25   simgrid::s4u::this_actor::execute(computation_amount, priority);
26
27   XBT_INFO("Goodbye now!");
28 }
29 };
30
31 int main(int argc, char *argv[])
32 {
33   simgrid::s4u::Engine e(&argc, argv);
34   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
35              "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
36   
37   e.registerFunction<test>("test");
38
39   e.loadPlatform(argv[1]);
40   e.loadDeployment(argv[2]);
41
42   e.run();
43
44   return 0;
45 }