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"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
14 simgrid::s4u::this_actor::sleep_for(200);
17 if (e.category == host_error) {
18 XBT_DEBUG("The host has died ... as expected. This actor silently stops");
20 XBT_ERROR("An unexpected exception has been raised.");
26 static void autostart()
28 simgrid::s4u::Host* host = simgrid::s4u::Host::by_name("Fafard");
29 XBT_INFO("starting a dummy process on %s ", host->get_cname());
31 simgrid::s4u::ActorPtr dummy_actor = simgrid::s4u::Actor::create("Dummy", host, dummy);
32 dummy_actor->set_auto_restart(true);
34 simgrid::s4u::this_actor::sleep_for(50);
36 XBT_INFO("powering off %s", host->get_cname());
39 simgrid::s4u::this_actor::sleep_for(10);
41 XBT_INFO("powering on %s", host->get_cname());
43 simgrid::s4u::this_actor::sleep_for(200);
46 int main(int argc, char* argv[])
48 simgrid::s4u::Engine e(&argc, argv);
49 e.load_platform(argv[1]);
51 simgrid::s4u::Actor::create("Autostart", simgrid::s4u::Host::by_name("Tremblay"), autostart);
54 XBT_INFO("Simulation time %g", e.get_clock());