X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0bfafcab47ae9cd7856bd8d129404c33079d6afe..7f00b09c7ebfa3b4e12c96c764ee7a0e0e07ec20:/examples/cpp/comm-dependent/s4u-comm-dependent.cpp?ds=sidebyside diff --git a/examples/cpp/comm-dependent/s4u-comm-dependent.cpp b/examples/cpp/comm-dependent/s4u-comm-dependent.cpp index bcf7bdae8d..d40c99feff 100644 --- a/examples/cpp/comm-dependent/s4u-comm-dependent.cpp +++ b/examples/cpp/comm-dependent/s4u-comm-dependent.cpp @@ -1,33 +1,34 @@ -/* Copyright (c) 2007-2021. 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. */ #include +namespace sg4 = simgrid::s4u; XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_dependent, "Messages specific for this s4u example"); -static void sender(simgrid::s4u::Mailbox* mailbox) +static void sender(sg4::Mailbox* mailbox) { - auto* computation_amount = new double(simgrid::s4u::this_actor::get_host()->get_speed()); - simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(2 * (*computation_amount)); - simgrid::s4u::CommPtr comm = mailbox->put_init(computation_amount, 7e6); + auto* computation_amount = new double(sg4::this_actor::get_host()->get_speed()); + sg4::ExecPtr exec = sg4::this_actor::exec_init(2 * (*computation_amount)); + sg4::CommPtr comm = mailbox->put_init(computation_amount, 7e6); exec->set_name("exec on sender")->add_successor(comm)->start(); - comm->set_name("comm to receiver")->vetoable_start(); + comm->set_name("comm to receiver")->start(); exec->wait(); comm->wait(); } -static void receiver(simgrid::s4u::Mailbox* mailbox) +static void receiver(sg4::Mailbox* mailbox) { double* received = nullptr; - double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed(); - simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(2 * computation_amount); - simgrid::s4u::CommPtr comm = mailbox->get_init()->set_dst_data((void**)&received, sizeof(double)); + double computation_amount = sg4::this_actor::get_host()->get_speed(); + sg4::ExecPtr exec = sg4::this_actor::exec_init(2 * computation_amount); + sg4::CommPtr comm = mailbox->get_init()->set_dst_data((void**)&received, sizeof(double)); comm->set_name("comm from sender")->add_successor(exec)->start(); - exec->set_name("exec on receiver")->vetoable_start(); + exec->set_name("exec on receiver")->start(); comm->wait(); exec->wait(); @@ -37,17 +38,17 @@ static void receiver(simgrid::s4u::Mailbox* mailbox) int main(int argc, char* argv[]) { - simgrid::s4u::Engine e(&argc, argv); + sg4::Engine e(&argc, argv); e.load_platform(argv[1]); - simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("Mailbox"); + sg4::Mailbox* mbox = e.mailbox_by_name_or_create("Mailbox"); - simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Tremblay"), sender, mbox); - simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("Jupiter"), receiver, mbox); + sg4::Actor::create("sender", e.host_by_name("Tremblay"), sender, mbox); + sg4::Actor::create("receiver", e.host_by_name("Jupiter"), receiver, mbox); e.run(); - XBT_INFO("Simulation time: %.3f", e.get_clock()); + XBT_INFO("Simulation time: %.3f", sg4::Engine::get_clock()); return 0; }