1 /* Copyright (c) 2020-2022. 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 // This is the MWE of https://framagit.org/simgrid/simgrid/-/issues/50
7 // The problem was occurring when suspending an actor that will be executed later in the same scheduling round
12 #include <simgrid/s4u.hpp>
15 XBT_LOG_NEW_DEFAULT_CATEGORY(mwe, "Minimum Working Example");
17 simgrid::s4u::ActorPtr receiver;
21 void operator()() const
23 XBT_INFO("Starting.");
24 auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
25 int data = *mailbox->get<int>();
26 XBT_INFO("Got %d at the end", data);
32 void operator()() const
34 XBT_INFO("Suspend the receiver...");
36 XBT_INFO("Resume the receiver...");
39 XBT_INFO("Sleeping 10 sec...");
40 simgrid::s4u::this_actor::sleep_for(10);
42 XBT_INFO("Sending a message to the receiver...");
43 auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
45 mailbox->put(&data, 4);
51 int main(int argc, char** argv)
53 simgrid::s4u::Engine engine(&argc, argv);
55 engine.load_platform(argv[1]);
56 simgrid::s4u::Host* host = engine.host_by_name("Tremblay");
58 simgrid::s4u::Actor::create("Suspender", host, Suspender());
59 receiver = simgrid::s4u::Actor::create("Receiver", host, Receiver());