- ThreadData* data = new ThreadData(*this, i);
- this->workers[i] = xbt_os_thread_create(worker_main, data);
- xbt_os_thread_bind(this->workers[i], core_bind);
+ this->workers[i] = new std::thread(worker_main, new ThreadData(*this, i));
+
+ /* Bind the worker to a core if possible */
+#if HAVE_PTHREAD_SETAFFINITY
+ pthread_t pthread = this->workers[i]->native_handle();
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(core_bind, &cpuset);
+ pthread_setaffinity_np(pthread, sizeof(cpu_set_t), &cpuset);