From b2943aabdf9582425c422bc7cba044e64fdb31d9 Mon Sep 17 00:00:00 2001 From: Takishipp Date: Mon, 4 Sep 2017 17:09:44 +0200 Subject: [PATCH] Almost converted phase 2 --- .../s4u/async-waitany/s4u_async-waitany.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/s4u/async-waitany/s4u_async-waitany.cpp b/examples/s4u/async-waitany/s4u_async-waitany.cpp index 97cf8b320a..c41916a87b 100644 --- a/examples/s4u/async-waitany/s4u_async-waitany.cpp +++ b/examples/s4u/async-waitany/s4u_async-waitany.cpp @@ -41,9 +41,12 @@ public: /* Here we are waiting for the completion of all communications */ while (!comms.empty()) { + comm=comms.back(); comms.pop_back(); + comm->wait(); } comms.clear(); + comm = nullptr; /* Here we are waiting for the completion of all tasks */ for (int i = 0; i < receivers_count; i++) { @@ -53,6 +56,9 @@ public: comm = nullptr; } +} +void operator()() +{ XBT_INFO("Goodbye now!"); } }; @@ -82,25 +88,27 @@ public: // returns the rank of the comm that just ended. Remove it. comm=comms.back(); comms.pop_back(); - // simgrid::s4u::this_actor::execute(comm); + comm->wait(); } comms.clear(); comm = nullptr; - +} +void operator()() +{ /* Here we tell to sender that all tasks are done */ simgrid::s4u::Mailbox::byName("finalize")->put(nullptr, 1); XBT_INFO("I'm done. See you!"); } +}; int main(int argc, char *argv[]) { simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv); + e->registerFunction("sender"); + e->registerFunction("receiver"); + e->loadDeployment(argv[2]); - - e->registerFunction("sender"); - // e->registerFunction("receiver"); - e->run(); delete e; -- 2.20.1