-RawContext::~RawContext()
-{
- SIMIX_context_stack_delete(this->stack_);
-}
-
-void RawContext::stop()
-{
- Context::stop();
- this->suspend();
-}
-
-void RawContextFactory::run_all()
-{
- if (raw_context_parallel)
- run_all_parallel();
- else
- run_all_serial();
-}
-
-void RawContextFactory::run_all_serial()
-{
- if (xbt_dynar_is_empty(simix_global->process_to_run))
- return;
-
- smx_actor_t first_process =
- xbt_dynar_get_as(simix_global->process_to_run, 0, smx_actor_t);
- raw_process_index = 1;
- static_cast<RawContext*>(first_process->context)->resume_serial();
-}
-
-void RawContextFactory::run_all_parallel()
-{
-#if HAVE_THREAD_CONTEXTS
- raw_threads_working = 0;
- if (raw_parmap == nullptr)
- raw_parmap = xbt_parmap_new(
- SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
- xbt_parmap_apply(raw_parmap,
- [](void* arg) {
- smx_actor_t process = static_cast<smx_actor_t>(arg);
- RawContext* context = static_cast<RawContext*>(process->context);
- context->resume_parallel();
- },
- simix_global->process_to_run);
-#else
- xbt_die("You asked for a parallel execution, but you don't have any threads.");
-#endif
-}
-
-void RawContext::suspend()
-{
- if (raw_context_parallel)
- RawContext::suspend_parallel();
- else
- RawContext::suspend_serial();
-}
-
-void RawContext::suspend_serial()
-{
- /* determine the next context */
- RawContext* next_context = nullptr;
- unsigned long int i = raw_process_index;
- raw_process_index++;
- if (i < xbt_dynar_length(simix_global->process_to_run)) {
- /* execute the next process */
- XBT_DEBUG("Run next process");
- next_context = static_cast<RawContext*>(xbt_dynar_get_as(simix_global->process_to_run, i, smx_actor_t)->context);
- } else {
- /* all processes were run, return to maestro */
- XBT_DEBUG("No more process to run");
- next_context = static_cast<RawContext*>(raw_maestro_context);
- }
- SIMIX_context_set_current(next_context);
- raw_swapcontext(&this->stack_top_, next_context->stack_top_);
-}
-
-void RawContext::suspend_parallel()