+ if (tasks.empty())
+ return false;
+
+ do {
+ // We don't want the callbacks to modify the vector we are iterating over:
+ tasks.swap(tasksTemp);
+
+ // Execute all the queued tasks:
+ for (auto& task : tasksTemp)
+ task();
+
+ tasksTemp.clear();
+ } while (not tasks.empty());
+
+ return true;
+}
+
+void Global::empty_trash()
+{
+ while (not actors_to_destroy.empty()) {
+ smx_actor_t actor = &actors_to_destroy.front();
+ actors_to_destroy.pop_front();
+ XBT_DEBUG("Getting rid of %p", actor);
+ intrusive_ptr_release(actor);
+ }
+#if SIMGRID_HAVE_MC
+ xbt_dynar_reset(dead_actors_vector);
+#endif
+}
+/**
+ * @brief Executes the actors in actors_to_run.
+ *
+ * The actors in actors_to_run are run (in parallel if possible). On exit, actors_to_run is empty, and actors_that_ran
+ * contains the list of actors that just ran. The two lists are swapped so, be careful when using them before and after
+ * a call to this function.
+ */
+void Global::run_all_actors()
+{
+ SIMIX_context_runall();