- if (factory_->parallel_) {
- // Save the thread number (my body) in an os-thread-specific area
- worker_id_ = factory_->threads_working_.fetch_add(1, std::memory_order_relaxed);
- // Save my current soul (either maestro, or one of the minions) in a permanent area
- SwappedContext* worker_context = static_cast<SwappedContext*>(self());
- factory_->workers_context_[worker_id_] = worker_context;
- // Switch my soul and the actor's one
- Context::set_current(this);
- worker_context->swap_into(this);
- // No body runs that soul anymore at this point, but it is stored in a safe place.
- // When the executed actor will do a blocking action, SIMIX_process_yield() will call suspend(), below.
- } else { // sequential execution
- SwappedContext* old = static_cast<SwappedContext*>(self());
- Context::set_current(this);
- old->swap_into(this);
+ SwappedContext* old = static_cast<SwappedContext*>(self());
+ if (SIMIX_context_is_parallel()) {
+ // Save my current soul (either maestro, or one of the minions) in a thread-specific area
+ worker_context_ = old;