1 /* Copyright (c) 2010-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 /******************** Non-deterministic message ordering *********************/
7 /* Server assumes a fixed order in the reception of messages from its clients */
8 /* which is incorrect because the message ordering is non-deterministic */
9 /******************************************************************************/
11 #include <simgrid/modelchecker.h>
12 #include <simgrid/s4u.hpp>
16 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
17 namespace sg4 = simgrid::s4u;
21 std::unique_ptr<int> received;
25 received = sg4::Mailbox::by_name("mymailbox")->get_unique<int>();
28 int value_got = *received;
29 MC_assert(value_got == 3);
34 static void client(int id)
36 auto* payload = new int(id);
37 sg4::Mailbox::by_name("mymailbox")->put(payload, 10000);
42 int main(int argc, char* argv[])
44 sg4::Engine e(&argc, argv);
46 e.load_platform(argv[1]);
48 sg4::Actor::create("server", e.host_by_name("HostA"), server);
49 sg4::Actor::create("client", e.host_by_name("HostB"), client, 1);
50 sg4::Actor::create("client", e.host_by_name("HostC"), client, 2);
51 sg4::Actor::create("client", e.host_by_name("HostD"), client, 3);