-/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
xbt_assert(mailbox->listen()); // True (1)
XBT_INFO("Task listen works on regular mailboxes");
- const std::string* res = static_cast<std::string*>(mailbox->get());
+ XBT_INFO("Mailbox::listen_from() returns %ld (should return my pid, which is %ld)", mailbox->listen_from(),
+ simgrid::s4u::this_actor::get_pid());
+
+ auto res = mailbox->get_unique<std::string>();
xbt_assert(*res == "Some data", "Data received: %s", res->c_str());
XBT_INFO("Data successfully received from regular mailbox");
- delete res;
sendComm->wait();
simgrid::s4u::Mailbox* mailbox2 = simgrid::s4u::Mailbox::by_name("mailbox2");
xbt_assert(mailbox2->listen()); // used to break.
XBT_INFO("Task listen works on asynchronous mailboxes");
- res = static_cast<std::string*>(mailbox2->get());
+ res = mailbox2->get_unique<std::string>();
xbt_assert(*res == "More data");
- delete res;
XBT_INFO("Data successfully received from asynchronous mailbox");
}
simgrid::s4u::Engine e(&argc, argv);
e.load_platform(argv[1]);
- simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Tremblay"), server);
+ simgrid::s4u::Actor::create("test", e.host_by_name("Tremblay"), server);
e.run();