Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Deprecate/remove Io::waitany() and waitanyfor()
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 25 Jul 2023 16:27:49 +0000 (18:27 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 25 Jul 2023 16:27:49 +0000 (18:27 +0200)
ChangeLog
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Io.hpp
src/bindings/python/simgrid_python.cpp
src/s4u/s4u_Io.cpp

index 1093891..281a60a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ SimGrid (3.34.1) not released (Target: fall 2023)
 
 S4U:
  - New class ActivitySet to ease wait_any()/test_any()/wait_all()
+   - Deprecate {Comm,Io,Exec}::{wait_any,wait_all,test_any} and friends
  - New function NetZone::add_route(host1, host2, links) when you don't need gateways
    Also add a variant with s4u::Link, when you don't want to specify the directions
    on symmetric routes.
@@ -17,6 +18,7 @@ Python:
  - Mailbox::get_async() does not return a pair anymore. Use comm.get_payload() instead.
  - Comm::waitall() is gone. Please use ActivitySet() instead.
  - Comm::waitallfor() is gone too. Its semantic was unclear on timeout anyway.
+ - Io::waitany() and waitanyfor() are gone. Please use ActivitySet() instead.
 
 ----------------------------------------------------------------------------
 
index a0f02ed..fc92aaa 100644 (file)
@@ -79,14 +79,12 @@ public:
 #ifndef DOXYGEN
   static ssize_t deprecated_wait_any_for(const std::vector<ExecPtr>& execs,
                                          double timeout); // XBT_ATTRIB_DEPRECATED_v339
-  /*! \static take a vector of s4u::ExecPtr and return when one of them is finished.
-   * The return value is the rank of the first finished ExecPtr. */
+
   XBT_ATTRIB_DEPRECATED_v339("Please use ActivitySet instead") static ssize_t
       wait_any(const std::vector<ExecPtr>& execs)
   {
     return deprecated_wait_any_for(execs, -1);
   }
-  /*! \static Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
   XBT_ATTRIB_DEPRECATED_v339("Please use ActivitySet instead") static ssize_t
       wait_any_for(const std::vector<ExecPtr>& execs, double timeout)
   {
index 2dc88c6..961ffd6 100644 (file)
@@ -28,16 +28,21 @@ protected:
   explicit Io(kernel::activity::IoImplPtr pimpl);
   Io* do_start() override;
 
+  static ssize_t deprecated_wait_any_for(const std::vector<IoPtr>& ios, double timeout);
+
 public:
   enum class OpType { READ, WRITE };
 
    /*! \static Initiate the creation of an I/O. Setters have to be called afterwards */
   static IoPtr init();
-  /*! \static take a vector of s4u::IoPtr and return when one of them is finished.
-   * The return value is the rank of the first finished IoPtr. */
-  static ssize_t wait_any(const std::vector<IoPtr>& ios) { return wait_any_for(ios, -1); }
-  /*! \static Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
-  static ssize_t wait_any_for(const std::vector<IoPtr>& ios, double timeout);
+#ifndef DOXYGEN
+  XBT_ATTRIB_DEPRECATED_v339("Please use ActivitySet instead") 
+  static ssize_t wait_any(const std::vector<IoPtr>& ios) { return deprecated_wait_any_for(ios, -1); }
+  XBT_ATTRIB_DEPRECATED_v339("Please use ActivitySet instead") 
+  static ssize_t wait_any_for(const std::vector<IoPtr>& ios, double timeout) { 
+    return deprecated_wait_any_for(ios, timeout); 
+  }
+#endif
 
   double get_remaining() const override;
   sg_size_t get_performed_ioops() const;
index 9b1846f..8722bf4 100644 (file)
@@ -706,12 +706,7 @@ PYBIND11_MODULE(simgrid, m)
       .def("test", &simgrid::s4u::Io::test, py::call_guard<py::gil_scoped_release>(),
            "Test whether the I/O is terminated.")
       .def("wait", &simgrid::s4u::Io::wait, py::call_guard<py::gil_scoped_release>(),
-           "Block until the completion of that I/O operation")
-      .def_static(
-          "wait_any_for", &simgrid::s4u::Io::wait_any_for, py::call_guard<py::gil_scoped_release>(),
-          "Block until the completion of any I/O in the list (or timeout) and return the index of the terminated one.")
-      .def_static("wait_any", &simgrid::s4u::Io::wait_any, py::call_guard<py::gil_scoped_release>(),
-                  "Block until the completion of any I/O in the list and return the index of the terminated one.");
+           "Block until the completion of that I/O operation");
 
   /* Class Exec */
   py::class_<simgrid::s4u::Exec, simgrid::s4u::ExecPtr, Activity>(m, "Exec",
index 7f0e45c..a0482b5 100644 (file)
@@ -3,6 +3,7 @@
 /* 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 <simgrid/s4u/ActivitySet.hpp>
 #include <simgrid/s4u/Disk.hpp>
 #include <simgrid/s4u/Io.hpp>
 #include <xbt/log.h>
@@ -94,12 +95,18 @@ Io* Io::do_start()
   return this;
 }
 
-ssize_t Io::wait_any_for(const std::vector<IoPtr>& ios, double timeout)
+ssize_t Io::deprecated_wait_any_for(const std::vector<IoPtr>& ios, double timeout)
 {
-  std::vector<ActivityPtr> activities;
+  ActivitySet set;
   for (const auto& io : ios)
-    activities.push_back(boost::dynamic_pointer_cast<Activity>(io));
-  return Activity::wait_any_for(activities, timeout);
+    set.push(boost::dynamic_pointer_cast<Activity>(io));
+
+  auto* ret = set.wait_any_for(timeout).get();
+  for (size_t i = 0; i < ios.size(); i++)
+    if (ios[i].get() == ret)
+      return i;
+
+  return -1;
 }
 
 IoPtr Io::set_disk(const_sg_disk_t disk)