- // Not found:
- if (idx == -1)
- return last;
- // Lift the index to the corresponding iterator:
- auto res = std::next(first, idx);
- (*res)->state_ = finished;
- return res;
+ return idx;
+ }
+
+ /*! take a vector s4u::CommPtr and return when all of them is finished. */
+ static void wait_all(std::vector<CommPtr> * comms)
+ {
+ // TODO: this should be a simcall or something
+ // TODO: we are missing a version with timeout
+ for (CommPtr comm : *comms) {
+ comm->wait();
+ }
+ }
+ /*! take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done). */
+ static int test_any(std::vector<CommPtr> * comms);
+
+ Activity* start() override;
+ Activity* wait() override;
+ Activity* wait(double timeout) override;
+
+ /** Start the comm, and ignore its result. It can be completely forgotten after that. */
+ Activity* detach();
+ /** Start the comm, and ignore its result. It can be completely forgotten after that. */
+ Activity* detach(void (*cleanFunction)(void*))
+ {
+ cleanFunction_ = cleanFunction;
+ return detach();