X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4de2a148bea34f550b79c07fb5e80ac36e6aa0e9..2ef958bf49890e4ac8fbe179f1d339b923fb67a8:/examples/cpp/dag-simple/s4u-dag-simple.cpp diff --git a/examples/cpp/dag-simple/s4u-dag-simple.cpp b/examples/cpp/dag-simple/s4u-dag-simple.cpp index f6411a636d..6f60e2e2ae 100644 --- a/examples/cpp/dag-simple/s4u-dag-simple.cpp +++ b/examples/cpp/dag-simple/s4u-dag-simple.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-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. */ @@ -16,23 +16,18 @@ int main(int argc, char* argv[]) std::set vetoed; e.track_vetoed_activities(&vetoed); - auto fafard = e.host_by_name("Fafard"); + auto* fafard = e.host_by_name("Fafard"); // Display the details on vetoed activities - sg4::Activity::on_veto_cb([](const sg4::Activity& a) { - const auto& exec = static_cast(a); // all activities are execs in this example - - XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", exec.get_cname(), + sg4::Exec::on_veto_cb([](sg4::Exec const& exec) { + XBT_INFO("Execution '%s' vetoed. Dependencies: %s; Ressources: %s", exec.get_cname(), (exec.dependencies_solved() ? "solved" : "NOT solved"), (exec.is_assigned() ? "assigned" : "NOT assigned")); }); - sg4::Activity::on_completion_cb([](sg4::Activity const& activity) { - const auto* exec = dynamic_cast(&activity); - if (exec == nullptr) // Only Execs are concerned here - return; - XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(), - exec->get_finish_time()); + sg4::Exec::on_completion_cb([](sg4::Exec const& exec) { + XBT_INFO("Execution '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(), exec.get_start_time(), + exec.get_finish_time()); }); // Define an amount of work that should take 1 second to execute. @@ -56,9 +51,9 @@ int main(int argc, char* argv[]) second_parent->set_host(fafard); // Start all activities that can actually start. - first_parent->vetoable_start(); - second_parent->vetoable_start(); - child->vetoable_start(); + first_parent->start(); + second_parent->start(); + child->start(); while (child->get_state() != sg4::Activity::State::FINISHED) { e.run();