1 /* Copyright (c) 2017-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"
9 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
15 simgrid::s4u::this_actor::sleep_for(200);
18 if (e.category == host_error) {
19 XBT_DEBUG("The host has died ... as expected. This actor silently stops");
21 XBT_ERROR("An unexpected exception has been raised.");
27 static void autostart()
29 simgrid::s4u::Host* host = simgrid::s4u::Host::by_name("Fafard");
30 XBT_INFO("starting a dummy process on %s ", host->get_cname());
32 simgrid::s4u::ActorPtr dummy_actor = simgrid::s4u::Actor::create("Dummy", host, dummy);
33 dummy_actor->set_auto_restart(true);
35 simgrid::s4u::this_actor::sleep_for(50);
37 XBT_INFO("powering off %s", host->get_cname());
40 simgrid::s4u::this_actor::sleep_for(10);
42 XBT_INFO("powering on %s", host->get_cname());
44 simgrid::s4u::this_actor::sleep_for(200);
47 int main(int argc, char* argv[])
49 simgrid::s4u::Engine e(&argc, argv);
50 e.load_platform(argv[1]);
52 simgrid::s4u::Actor::create("Autostart", simgrid::s4u::Host::by_name("Tremblay"), autostart);
55 XBT_INFO("Simulation time %g", e.get_clock());