*/
#include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_exiting, "Messages specific for this s4u example");
static void actor_a()
{
// Register a lambda function to be executed once it stops
- simgrid::s4u::this_actor::on_exit([](bool /*failed*/) { XBT_INFO("I stop now"); });
+ sg4::this_actor::on_exit([](bool /*failed*/) { XBT_INFO("I stop now"); });
- simgrid::s4u::this_actor::sleep_for(1);
+ sg4::this_actor::sleep_for(1);
}
static void actor_b()
{
- simgrid::s4u::this_actor::sleep_for(2);
+ sg4::this_actor::sleep_for(2);
}
static void actor_c()
{
// Register a lambda function to be executed once it stops
- simgrid::s4u::this_actor::on_exit([](bool failed) {
+ sg4::this_actor::on_exit([](bool failed) {
if (failed) {
XBT_INFO("I was killed!");
if (xbt_log_no_loc)
XBT_INFO("Exiting gracefully.");
});
- simgrid::s4u::this_actor::sleep_for(3);
+ sg4::this_actor::sleep_for(3);
XBT_INFO("And now, induce a deadlock by waiting for a message that will never come\n\n");
- simgrid::s4u::Mailbox::by_name("nobody")->get<void>();
+ sg4::Mailbox::by_name("nobody")->get<void>();
xbt_die("Receiving is not supposed to succeed when nobody is sending");
}
int main(int argc, char* argv[])
{
- simgrid::s4u::Engine e(&argc, argv);
+ sg4::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
e.load_platform(argv[1]); /* - Load the platform description */
/* Register a callback in the Actor::on_termination signal. It will be called for every terminated actors */
- simgrid::s4u::Actor::on_termination.connect(
- [](simgrid::s4u::Actor const& actor) { XBT_INFO("Actor %s terminates now", actor.get_cname()); });
+ sg4::Actor::on_termination.connect(
+ [](sg4::Actor const& actor) { XBT_INFO("Actor %s terminates now", actor.get_cname()); });
/* Register a callback in the Actor::on_destruction signal. It will be called for every destructed actors */
- simgrid::s4u::Actor::on_destruction.connect(
- [](simgrid::s4u::Actor const& actor) { XBT_INFO("Actor %s gets destroyed now", actor.get_cname()); });
+ sg4::Actor::on_destruction.connect(
+ [](sg4::Actor const& actor) { XBT_INFO("Actor %s gets destroyed now", actor.get_cname()); });
/* Create some actors */
- simgrid::s4u::Actor::create("A", simgrid::s4u::Host::by_name("Tremblay"), actor_a);
- simgrid::s4u::Actor::create("B", simgrid::s4u::Host::by_name("Fafard"), actor_b);
- simgrid::s4u::Actor::create("C", simgrid::s4u::Host::by_name("Ginette"), actor_c);
+ sg4::Actor::create("A", sg4::Host::by_name("Tremblay"), actor_a);
+ sg4::Actor::create("B", sg4::Host::by_name("Fafard"), actor_b);
+ sg4::Actor::create("C", sg4::Host::by_name("Ginette"), actor_c);
e.run(); /* - Run the simulation */