X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d68dcbd4cd142d73e90ab9376c34a435c10e1dc6..HEAD:/teshsuite/s4u/actor/actor.cpp diff --git a/teshsuite/s4u/actor/actor.cpp b/teshsuite/s4u/actor/actor.cpp index ccf99d53f6..37548fb614 100644 --- a/teshsuite/s4u/actor/actor.cpp +++ b/teshsuite/s4u/actor/actor.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2018. 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. */ @@ -10,10 +10,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example") static void worker() { simgrid::s4u::this_actor::sleep_for(.5); - XBT_INFO("Worker started (PID:%ld, PPID:%ld)", simgrid::s4u::this_actor::getPid(), - simgrid::s4u::this_actor::getPpid()); - while (1) { - XBT_INFO("Plop i am %ssuspended", simgrid::s4u::this_actor::isSuspended() ? "" : "not "); + XBT_INFO("Worker started (PID:%ld, PPID:%ld)", simgrid::s4u::this_actor::get_pid(), + simgrid::s4u::this_actor::get_ppid()); + while (simgrid::s4u::this_actor::get_host()->is_on()) { + simgrid::s4u::this_actor::yield(); + XBT_INFO("Plop i am not suspended"); simgrid::s4u::this_actor::sleep_for(1); } XBT_INFO("I'm done. See you!"); @@ -22,17 +23,16 @@ static void worker() static void master() { simgrid::s4u::this_actor::sleep_for(1); - std::vector* actor_list = new std::vector(); - simgrid::s4u::this_actor::getHost()->actorList(actor_list); + std::vector actor_list = simgrid::s4u::this_actor::get_host()->get_all_actors(); - for (auto const& actor : *actor_list) { + for (auto const& actor : actor_list) { XBT_INFO("Actor (pid=%ld, ppid=%ld, name=%s)", actor->get_pid(), actor->get_ppid(), actor->get_cname()); - if (simgrid::s4u::this_actor::getPid() != actor->get_pid()) + if (simgrid::s4u::this_actor::get_pid() != actor->get_pid()) actor->kill(); } simgrid::s4u::ActorPtr actor = - simgrid::s4u::Actor::create("worker from master", simgrid::s4u::this_actor::getHost(), worker); + simgrid::s4u::Actor::create("worker from master", simgrid::s4u::this_actor::get_host(), worker); simgrid::s4u::this_actor::sleep_for(2); XBT_INFO("Suspend Actor (pid=%ld)", actor->get_pid()); @@ -48,20 +48,19 @@ static void master() simgrid::s4u::this_actor::sleep_for(2); actor->kill(); - delete actor_list; XBT_INFO("Goodbye now!"); } int main(int argc, char* argv[]) { simgrid::s4u::Engine e(&argc, argv); - e.loadPlatform(argv[1]); + e.load_platform(argv[1]); - simgrid::s4u::Actor::create("master", simgrid::s4u::Host::by_name("Tremblay"), master); - simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker); + simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), master); + simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker); e.run(); - XBT_INFO("Simulation time %g", e.getClock()); + XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock()); return 0; }