X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1a64ca4c11a1eb7ba2ecd102f877ac571486a034..3f53fa0e417dcf21536630d285ec51c0deced9a8:/examples/cpp/synchro-barrier/s4u-synchro-barrier.cpp diff --git a/examples/cpp/synchro-barrier/s4u-synchro-barrier.cpp b/examples/cpp/synchro-barrier/s4u-synchro-barrier.cpp index 28aba1fda0..b7944d8686 100644 --- a/examples/cpp/synchro-barrier/s4u-synchro-barrier.cpp +++ b/examples/cpp/synchro-barrier/s4u-synchro-barrier.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-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. */ @@ -6,9 +6,10 @@ #include "simgrid/s4u.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category"); +namespace sg4 = simgrid::s4u; /// Wait on the barrier then leave -static void worker(simgrid::s4u::BarrierPtr barrier) +static void worker(sg4::BarrierPtr barrier) { XBT_INFO("Waiting on the barrier"); barrier->wait(); @@ -19,11 +20,11 @@ static void worker(simgrid::s4u::BarrierPtr barrier) /// Spawn actor_count-1 workers and do a barrier with them static void master(int actor_count) { - simgrid::s4u::BarrierPtr barrier = simgrid::s4u::Barrier::create(actor_count); + sg4::BarrierPtr barrier = sg4::Barrier::create(actor_count); XBT_INFO("Spawning %d workers", actor_count - 1); for (int i = 0; i < actor_count - 1; i++) { - simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker, barrier); + sg4::Actor::create("worker", sg4::Host::by_name("Jupiter"), worker, barrier); } XBT_INFO("Waiting on the barrier"); @@ -34,15 +35,15 @@ static void master(int actor_count) int main(int argc, char **argv) { - simgrid::s4u::Engine e(&argc, argv); + sg4::Engine e(&argc, argv); // Parameter: Number of actores in the barrier xbt_assert(argc >= 2, "Usage: %s \n", argv[0]); int actor_count = std::stoi(argv[1]); xbt_assert(actor_count > 0, " must be greater than 0"); - e.load_platform("../../platforms/two_hosts.xml"); - simgrid::s4u::Actor::create("master", simgrid::s4u::Host::by_name("Tremblay"), master, actor_count); + e.load_platform(argc > 2 ? argv[2] : "../../platforms/two_hosts.xml"); + sg4::Actor::create("master", e.host_by_name("Tremblay"), master, actor_count); e.run(); return 0;