Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use a reference for ExecImpl::wait_any_for()'s vector.
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index 59ca43c..2d553a8 100644 (file)
@@ -168,9 +168,9 @@ void ExecImpl::finish()
       continue;                                 // if process handling comm is killed
     if (auto* observer =
             dynamic_cast<kernel::actor::ExecutionWaitanySimcall*>(simcall->observer_)) { // simcall is a wait_any?
-      const auto* execs = observer->get_execs();
+      const auto& execs = observer->get_execs();
 
-      for (auto* exec : *execs) {
+      for (auto* exec : execs) {
         exec->unregister_simcall(simcall);
 
         if (simcall->timeout_cb_) {
@@ -180,8 +180,8 @@ void ExecImpl::finish()
       }
 
       if (not MC_is_active() && not MC_record_replay_is_active()) {
-        auto element = std::find(execs->begin(), execs->end(), this);
-        int rank     = element != execs->end() ? static_cast<int>(std::distance(execs->begin(), element)) : -1;
+        auto element = std::find(execs.begin(), execs.end(), this);
+        int rank     = element != execs.end() ? static_cast<int>(std::distance(execs.begin(), element)) : -1;
         observer->set_result(rank);
       }
     }
@@ -237,21 +237,21 @@ ActivityImpl* ExecImpl::migrate(s4u::Host* to)
   return this;
 }
 
-void ExecImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl*>* execs, double timeout)
+void ExecImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl*>& execs, double timeout)
 {
   if (timeout < 0.0) {
     issuer->simcall_.timeout_cb_ = nullptr;
   } else {
-    issuer->simcall_.timeout_cb_ = simgrid::simix::Timer::set(SIMIX_get_clock() + timeout, [issuer, execs]() {
+    issuer->simcall_.timeout_cb_ = simgrid::simix::Timer::set(SIMIX_get_clock() + timeout, [issuer, &execs]() {
       issuer->simcall_.timeout_cb_ = nullptr;
-      for (auto* exec : *execs)
+      for (auto* exec : execs)
         exec->unregister_simcall(&issuer->simcall_);
       // default result (-1) is set in mc::ExecutionWaitanySimcall
       issuer->simcall_answer();
     });
   }
 
-  for (auto* exec : *execs) {
+  for (auto* exec : execs) {
     /* associate this simcall to the the synchro */
     exec->simcalls_.push_back(&issuer->simcall_);