-/* Copyright (c) 2010-2022. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2023. 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_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
-int tasks_done = 0;
-
-XBT_ATTRIB_NORETURN static void actor_daemon()
+XBT_ATTRIB_NORETURN static void actor_daemon(int& tasks_done)
{
const simgrid::s4u::Host* host = simgrid::s4u::Host::current();
XBT_INFO(" Start daemon on %s (%f)", host->get_cname(), host->get_speed());
{
XBT_INFO(" Start RX");
try {
- auto payload = simgrid::s4u::Mailbox::by_name("comm")->get<std::string>();
+ const auto* payload = simgrid::s4u::Mailbox::by_name("comm")->get<std::string>();
XBT_INFO(" Receive message: %s", payload->c_str());
} catch (const simgrid::HostFailureException&) {
XBT_INFO(" Receive message: HOST_FAILURE");
simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter");
simgrid::s4u::ActorPtr daemon;
simgrid::s4u::VirtualMachine* vm0 = nullptr;
+ int tasks_done = 0;
switch (test_number) {
case 1:
// Create a process running a simple task on a host and turn the host off during the execution of the actor.
XBT_INFO("Test 1:");
XBT_INFO(" Create an actor on Jupiter");
- simgrid::s4u::Actor::create("actor_daemon", jupiter, actor_daemon);
+ simgrid::s4u::Actor::create("actor_daemon", jupiter, actor_daemon, std::ref(tasks_done));
simgrid::s4u::this_actor::sleep_for(3);
XBT_INFO(" Turn off Jupiter");
jupiter->turn_off();
// adsein: This can be one additional test, to check that you cannot shutdown twice a host
jupiter->turn_off();
try {
- simgrid::s4u::Actor::create("actor_daemon", jupiter, actor_daemon);
+ simgrid::s4u::Actor::create("actor_daemon", jupiter, actor_daemon, std::ref(tasks_done));
simgrid::s4u::this_actor::sleep_for(10);
XBT_INFO(" Test 2 does crash as it should. This message will not be displayed.");
} catch (const simgrid::HostFailureException&) {
vm0 = jupiter->create_vm("vm0", 1);
vm0->start();
- daemon = simgrid::s4u::Actor::create("actor_daemon", vm0, actor_daemon);
- simgrid::s4u::Actor::create("actor_daemonJUPI", jupiter, actor_daemon);
+ daemon = simgrid::s4u::Actor::create("actor_daemon", vm0, actor_daemon, std::ref(tasks_done));
+ simgrid::s4u::Actor::create("actor_daemonJUPI", jupiter, actor_daemon, std::ref(tasks_done));
daemon->suspend();
vm0->set_bound(90);