- BoostContext* context = nullptr;
- if (BoostContext::parallel_)
-#if HAVE_THREAD_CONTEXTS
- context = this->new_context<BoostParallelContext>(std::move(code), cleanup_func, process);
-#else
- xbt_die("No support for parallel execution");
-#endif
- else
- context = this->new_context<BoostSerialContext>(std::move(code), cleanup_func, process);
- return context;
-}
-
-void BoostContextFactory::run_all()
-{
-#if HAVE_THREAD_CONTEXTS
- if (BoostContext::parallel_) {
- BoostContext::threads_working_ = 0;
- if (not BoostContext::parmap_)
- BoostContext::parmap_ =
- new simgrid::xbt::Parmap<smx_actor_t>(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
- BoostContext::parmap_->apply(
- [](smx_actor_t process) {
- BoostContext* context = static_cast<BoostContext*>(process->context);
- return context->resume();
- },
- simix_global->process_to_run);
- } else
-#endif
- {
- if (simix_global->process_to_run.empty())
- return;
- smx_actor_t first_process = simix_global->process_to_run.front();
- BoostContext::process_index_ = 1;
- /* execute the first process */
- static_cast<BoostContext*>(first_process->context)->resume();
- }