From 7915da3b4384df6fb6f40629e1ca8ebfe9157b48 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 18 Oct 2020 02:25:10 +0200 Subject: [PATCH] Cosmetics in the ns3 teshsuite --- .../ns3-from-src-to-itself.cpp | 14 +++++--------- .../ns3-simultaneous-send-rcv.cpp | 12 +++++------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/teshsuite/s4u/ns3-from-src-to-itself/ns3-from-src-to-itself.cpp b/teshsuite/s4u/ns3-from-src-to-itself/ns3-from-src-to-itself.cpp index dbe6027952..22bc946986 100644 --- a/teshsuite/s4u/ns3-from-src-to-itself/ns3-from-src-to-itself.cpp +++ b/teshsuite/s4u/ns3-from-src-to-itself/ns3-from-src-to-itself.cpp @@ -13,12 +13,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u tests"); const int payload = 1000; const int nb_message_to_send = 5; -// const double sleep_time = 5; const int nb_sender = 2; int nb_messages_sent = 0; -simgrid::s4u::Mailbox* box; +simgrid::s4u::Mailbox* box = simgrid::s4u::Mailbox::by_name("test"); static void test_send() { @@ -27,7 +26,6 @@ static void test_send() XBT_VERB("start sending test #%i", nb_messages_sent); box->put(new int(nb_messages_sent), payload); XBT_VERB("done sending test #%i", nb_messages_sent); - // simgrid::s4u::this_actor::sleep_until(sleep_time * (nb_message + 1)); } } @@ -49,12 +47,10 @@ int main(int argc, char* argv[]) e.load_platform(argv[1]); - auto host = e.get_all_hosts()[0]; - auto receiver = simgrid::s4u::Actor::create("receiver", host, test_receive); - auto send_same = simgrid::s4u::Actor::create("send_same", host, test_send); - auto send_other = simgrid::s4u::Actor::create("send_other", e.get_all_hosts()[1], test_send); - - box = simgrid::s4u::Mailbox::by_name("test"); + auto hosts = e.get_all_hosts(); + simgrid::s4u::Actor::create("receiver", hosts[0], test_receive); + simgrid::s4u::Actor::create("send_same", hosts[0], test_send); + simgrid::s4u::Actor::create("send_other", hosts[1], test_send); e.run(); diff --git a/teshsuite/s4u/ns3-simultaneous-send-rcv/ns3-simultaneous-send-rcv.cpp b/teshsuite/s4u/ns3-simultaneous-send-rcv/ns3-simultaneous-send-rcv.cpp index e087d39ba7..fac647598b 100644 --- a/teshsuite/s4u/ns3-simultaneous-send-rcv/ns3-simultaneous-send-rcv.cpp +++ b/teshsuite/s4u/ns3-simultaneous-send-rcv/ns3-simultaneous-send-rcv.cpp @@ -18,7 +18,7 @@ const int nb_sender = 100; int nb_messages_sent = 0; -simgrid::s4u::Mailbox* box; +simgrid::s4u::Mailbox* box = simgrid::s4u::Mailbox::by_name("test"); static void test_send(){ for (int nb_message = 0; nb_message < nb_message_to_send; nb_message++) { @@ -48,13 +48,11 @@ int main(int argc, char *argv[]) e.load_platform(argv[1]); - simgrid::s4u::ActorPtr receiver = simgrid::s4u::Actor::create("receiver", e.get_all_hosts()[0], test_receive); - for (int i = 0; i < nb_sender; i++) - simgrid::s4u::Actor::create("sender_" + std::to_string(i), e.get_all_hosts()[i % (e.get_host_count() - 1) + 1], - test_send); + auto hosts = e.get_all_hosts(); - box = simgrid::s4u::Mailbox::by_name("test"); - box->set_receiver(receiver); + simgrid::s4u::Actor::create("receiver", hosts[0], test_receive); + for (int i = 0; i < nb_sender; i++) + simgrid::s4u::Actor::create("sender_" + std::to_string(i), hosts[i % (e.get_host_count() - 1) + 1], test_send); e.run(); -- 2.20.1