1 /* Copyright (c) 2020-2023. 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");
19 void operator()() const
21 XBT_INFO("Starting.");
22 auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
23 int data = *mailbox->get<int>();
24 XBT_INFO("Got %d at the end", data);
29 const simgrid::s4u::ActorPtr& receiver;
32 explicit Suspender(const simgrid::s4u::ActorPtr& receiver) : receiver(receiver) {}
34 void operator()() const
36 XBT_INFO("Suspend the receiver...");
38 XBT_INFO("Resume the receiver...");
41 XBT_INFO("Sleeping 10 sec...");
42 simgrid::s4u::this_actor::sleep_for(10);
44 XBT_INFO("Sending a message to the receiver...");
45 auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
47 mailbox->put(&data, 4);
53 int main(int argc, char** argv)
55 simgrid::s4u::Engine engine(&argc, argv);
57 engine.load_platform(argv[1]);
58 simgrid::s4u::Host* host = engine.host_by_name("Tremblay");
60 simgrid::s4u::ActorPtr receiver;
61 simgrid::s4u::Actor::create("Suspender", host, Suspender(receiver));
62 receiver = simgrid::s4u::Actor::create("Receiver", host, Receiver());