- uintptr_t worker_id = __sync_fetch_and_add(&threads_working_, 1);
- xbt_os_thread_set_specific(worker_id_key_, reinterpret_cast<void*>(worker_id));
- ParallelRawContext* worker_context = static_cast<ParallelRawContext*>(SIMIX_context_self());
- workers_context_[worker_id] = worker_context;
- XBT_DEBUG("Saving worker stack %zu", worker_id);
- SIMIX_context_set_current(this);
+ worker_id_ = threads_working_.fetch_add(1, std::memory_order_relaxed);
+ ParallelRawContext* worker_context = static_cast<ParallelRawContext*>(self());
+ workers_context_[worker_id_] = worker_context;
+ XBT_DEBUG("Saving worker stack %zu", worker_id_);
+ Context::set_current(this);