delete this;
}
+/** Execute all the tasks that are queued, e.g. `.then()` callbacks of futures. */
+bool Global::execute_tasks()
+{
+ xbt_assert(tasksTemp.empty());
+
+ 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()) {
#endif
if (simix_global == nullptr) {
+ surf_init(argc, argv); /* Initialize SURF structures */
+
simix_global.reset(new simgrid::simix::Global());
simix_global->maestro_process = nullptr;
-
- surf_init(argc, argv); /* Initialize SURF structures */
SIMIX_context_mod_init();
// Either create a new context with maestro or create
if (simgrid::config::get_value<bool>("clean-atexit"))
atexit(SIMIX_clean);
-
- if (_sg_cfg_exit_asap)
- exit(0);
}
int smx_cleaned = 0;
XBT_DEBUG("Handling the processes whose action failed (if any)");
while ((action = model->extract_failed_action())) {
XBT_DEBUG(" Handling Action %p",action);
- SIMIX_simcall_exit(static_cast<simgrid::kernel::activity::ActivityImpl*>(action->get_data()));
+ if (action->get_activity() != nullptr)
+ simgrid::kernel::activity::ActivityImplPtr(action->get_activity())->post();
}
XBT_DEBUG("Handling the processes whose action terminated normally (if any)");
while ((action = model->extract_done_action())) {
XBT_DEBUG(" Handling Action %p",action);
- if (action->get_data() == nullptr)
+ if (action->get_activity() == nullptr)
XBT_DEBUG("probably vcpu's action %p, skip", action);
else
- SIMIX_simcall_exit(static_cast<simgrid::kernel::activity::ActivityImpl*>(action->get_data()));
+ simgrid::kernel::activity::ActivityImplPtr(action->get_activity())->post();
}
}
}
return result;
}
-/** Execute all the tasks that are queued
- *
- * e.g. `.then()` callbacks of futures.
- **/
-static bool SIMIX_execute_tasks()
-{
- xbt_assert(simix_global->tasksTemp.empty());
-
- if (simix_global->tasks.empty())
- return false;
-
- do {
- // We don't want the callbacks to modify the vector we are iterating over:
- simix_global->tasks.swap(simix_global->tasksTemp);
-
- // Execute all the queued tasks:
- for (auto& task : simix_global->tasksTemp)
- task();
-
- simix_global->tasksTemp.clear();
- } while (not simix_global->tasks.empty());
-
- return true;
-}
-
/**
* @ingroup SIMIX_API
* @brief Run the main simulation loop.
#endif
}
- SIMIX_execute_tasks();
+ simix_global->execute_tasks();
while (not simix_global->actors_to_run.empty()) {
XBT_DEBUG("New Sub-Schedule Round; size(queue)=%zu", simix_global->actors_to_run.size());
}
}
- SIMIX_execute_tasks();
+ simix_global->execute_tasks();
do {
SIMIX_wake_processes();
- } while (SIMIX_execute_tasks());
+ } while (simix_global->execute_tasks());
/* If only daemon processes remain, cancel their actions, mark them to die and reschedule them */
if (simix_global->process_list.size() == simix_global->daemons.size())
bool again = false;
do {
again = SIMIX_execute_timers();
- if (SIMIX_execute_tasks())
+ if (simix_global->execute_tasks())
again = true;
SIMIX_wake_processes();
} while (again);