- // Map to dynar<Synchro*>:
- xbt_dynar_t comms = xbt_dynar_new(sizeof(simgrid::kernel::activity::ActivityImpl*), NULL);
- for (I iter = first; iter != last; iter++) {
- Comm& comm = **iter;
- if (comm.state_ == inited)
- comm.start();
- xbt_assert(comm.state_ == started);
- xbt_dynar_push_as(comms, simgrid::kernel::activity::ActivityImpl*, comm.pimpl_);
- }
- // Call the underlying simcall:
- int idx = simcall_comm_waitany(comms, timeout);
- xbt_dynar_free(&comms);
- // 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;