X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/416b0ba5fbba4c1a7759e44c568392fc832f84e3..cf5016e3131d80972455d3501e19a9c5bd1df822:/src/s4u/s4u_Comm.cpp diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 64e9ea3480..3ddc1d6143 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -395,7 +395,7 @@ Comm* Comm::detach() return this; } -ssize_t Comm::test_any(const std::vector& comms) +ssize_t Comm::test_any(const std::vector& comms) // XBT_ATTRIB_DEPRECATED_v339 { std::vector activities; for (const auto& comm : comms) @@ -461,7 +461,7 @@ Comm* Comm::wait_for(double timeout) return this; } -ssize_t Comm::deprecated_wait_any_for(const std::vector& comms, double timeout) +ssize_t Comm::deprecated_wait_any_for(const std::vector& comms, double timeout) // XBT_ATTRIB_DEPRECATED_v339 { std::vector activities; for (const auto& comm : comms) @@ -496,18 +496,12 @@ size_t Comm::wait_all_for(const std::vector& comms, double timeout) // return comms.size(); } - double deadline = Engine::get_clock() + timeout; - std::vector waited_comm(1, nullptr); - for (size_t i = 0; i < comms.size(); i++) { - double wait_timeout = std::max(0.0, deadline - Engine::get_clock()); - waited_comm[0] = comms[i]; - // Using wait_any_for() here (and not wait_for) because we don't want comms to be invalidated on timeout - if (wait_any_for(waited_comm, wait_timeout) == -1) { - XBT_DEBUG("Timeout (%g): i = %zu", wait_timeout, i); - return i; - } - } - return comms.size(); + ActivitySet set; + for (auto comm : comms) + set.push(comm); + set.wait_all_for(timeout); + + return set.size(); } } // namespace simgrid::s4u /* **************************** Public C interface *************************** */