1 /* Copyright (c) 2010-2021. 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/s4u.hpp>
12 namespace sg4 = simgrid::s4u;
16 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
20 auto mb = sg4::Mailbox::by_name("mymailbox");
22 for (int count = 0; count < N; count++) {
23 int *received = mb->get<int>();
24 value_got = *received;
27 xbt_assert(value_got == 3);
32 static void client(int id)
34 auto* payload = new int(id);
35 XBT_INFO("Sending %d", id);
36 sg4::Mailbox::by_name("mymailbox")->put(payload, 10000);
40 int main(int argc, char* argv[])
42 sg4::Engine e(&argc, argv);
44 std::string platform_file = "small_platform.xml";
46 platform_file = argv[1];
47 e.load_platform(platform_file);
49 sg4::Actor::create("server", sg4::Host::by_name("Tremblay"), server);
50 sg4::Actor::create("client", sg4::Host::by_name("Jupiter"), client, 1);
51 sg4::Actor::create("client", sg4::Host::by_name("Bourassa"), client, 2);
52 sg4::Actor::create("client", sg4::Host::by_name("Ginette"), client, 3);