+ if (SIMIX_context_is_parallel()) {
+ // Get some more work to directly swap into the next executable actor instead of yielding back to the parmap
+ boost::optional<smx_actor_t> next_work = factory_->parmap_->next();
+ SwappedContext* next_context;
+ if (next_work) {
+ // There is a next soul to embody (ie, another executable actor)
+ XBT_DEBUG("Run next process");
+ next_context = static_cast<SwappedContext*>(next_work.get()->context_.get());
+ } else {
+ // All actors were run, go back to the parmap context
+ XBT_DEBUG("No more actors to run");
+ // worker_context_ is my own soul, stored in thread_local when starting the scheduling round
+ next_context = worker_context_;
+ // When given that soul, the body will wait for the next scheduling round
+ }
+
+ // Get the next soul to run, either from another actor or the initial minion's one
+ Context::set_current(next_context);
+ this->swap_into(next_context);
+
+ } else { // sequential execution
+ /* determine the next context */
+ SwappedContext* next_context;
+ unsigned long int i = factory_->process_index_;
+ factory_->process_index_++;
+
+ if (i < simix_global->actors_to_run.size()) {
+ /* Actually swap into the next actor directly without transiting to maestro */
+ XBT_DEBUG("Run next actor");
+ next_context = static_cast<SwappedContext*>(simix_global->actors_to_run[i]->context_.get());
+ } else {
+ /* all processes were run, actually return to maestro */
+ XBT_DEBUG("No more actors to run");
+ next_context = factory_->maestro_context_;
+ }
+ Context::set_current(next_context);
+ this->swap_into(next_context);
+ }