Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't try to get front() from an empty list.
[simgrid.git] / src / simix / ActorImpl.cpp
index 318e5ed..aac766f 100644 (file)
@@ -79,8 +79,9 @@ void SIMIX_process_cleanup(smx_actor_t process)
   xbt_os_mutex_acquire(simix_global->mutex);
 
   /* cancel non-blocking communications */
-  smx_activity_t synchro = process->comms.front();
   while (not process->comms.empty()) {
+    smx_activity_t synchro = process->comms.front();
+    process->comms.pop_front();
     simgrid::kernel::activity::CommImplPtr comm =
         boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
@@ -104,8 +105,6 @@ void SIMIX_process_cleanup(smx_actor_t process)
     } else {
       xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro.get());
     }
-    process->comms.pop_front();
-    synchro = process->comms.front();
     comm->cancel();
   }
 
@@ -723,7 +722,12 @@ smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, doubl
    * The C API should first be properly replaced with the C++ one, which is a fair amount of work.
    */
   intrusive_ptr_add_ref(process);
-  SIMIX_process_on_exit(process, (int_f_pvoid_pvoid_t)SIMIX_process_join_finish, &*res);
+  SIMIX_process_on_exit(process,
+                        [](void*, void* arg) {
+                          return simgrid::simix::kernelImmediate(
+                              [&] { return SIMIX_process_join_finish(SMX_EXIT_SUCCESS, arg); });
+                        },
+                        &*res);
   return res;
 }
 
@@ -824,11 +828,8 @@ xbt_dynar_t SIMIX_process_get_runnable()
 /** @brief Returns the process from PID. */
 smx_actor_t SIMIX_process_from_PID(aid_t PID)
 {
-  try {
-    return simix_global->process_list.at(PID);
-  } catch (std::out_of_range& unfound) {
-    return nullptr;
-  }
+  auto process = simix_global->process_list.find(PID);
+  return process == simix_global->process_list.end() ? nullptr : process->second;
 }
 
 /** @brief returns a dynar containing all currently existing processes */