-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2021. 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. */
int tasks_done = 0;
-static void actor_daemon()
+XBT_ATTRIB_NORETURN static void actor_daemon()
{
const simgrid::s4u::Host* host = simgrid::s4u::Host::current();
XBT_INFO(" Start daemon on %s (%f)", host->get_cname(), host->get_speed());
simgrid::s4u::this_actor::execute(host->get_speed());
tasks_done++;
}
- XBT_INFO(" daemon done. See you!");
+ xbt_die(" daemon done. See you!");
}
static void commTX()
{
XBT_INFO(" Start TX");
- simgrid::s4u::Mailbox::by_name("comm")->put_init(xbt_strdup("COMM"), 100000000)->detach();
+ auto* payload = new std::string("COMM");
+ simgrid::s4u::Mailbox::by_name("comm")->put_init(payload, 100000000)->detach();
// We should wait a bit (if not the process will end before the communication, hence an exception on the other side).
try {
simgrid::s4u::this_actor::sleep_for(30);
} catch (const simgrid::HostFailureException&) {
XBT_INFO("The host has died ... as expected.");
}
+ delete payload;
+
XBT_INFO(" TX done");
}
static void commRX()
{
- char* payload = nullptr;
XBT_INFO(" Start RX");
try {
- payload = static_cast<char*>(simgrid::s4u::Mailbox::by_name("comm")->get());
- XBT_INFO(" Receive message: %s", payload);
+ auto payload = simgrid::s4u::Mailbox::by_name("comm")->get_unique<std::string>();
+ XBT_INFO(" Receive message: %s", payload->c_str());
} catch (const simgrid::HostFailureException&) {
XBT_INFO(" Receive message: HOST_FAILURE");
} catch (const simgrid::NetworkFailureException&) {
XBT_INFO(" Receive message: TRANSFER_FAILURE");
}
- xbt_free(payload);
XBT_INFO(" RX Done");
}