X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/97251bcf38f652d22db8a323d026209b52348a76..326d152a10a4c9907e5e54f104f253155abdc851:/src/include/xbt/parmap.hpp diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index dd5037f7aa..00f4b8c94b 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -90,7 +90,6 @@ private: */ virtual void worker_wait(unsigned) = 0; - protected: Parmap& parmap; }; @@ -225,7 +224,7 @@ template void Parmap::apply(void (*fun)(T), const std::vector */ template boost::optional Parmap::next() { - unsigned index = this->index++; + unsigned index = this->index.fetch_add(1, std::memory_order_relaxed); if (index < this->data->size()) return (*this->data)[index]; else @@ -237,11 +236,11 @@ template boost::optional Parmap::next() */ template void Parmap::work() { - unsigned index = this->index++; unsigned length = this->data->size(); + unsigned index = this->index.fetch_add(1, std::memory_order_relaxed); while (index < length) { this->fun((*this->data)[index]); - index = this->index++; + index = this->index.fetch_add(1, std::memory_order_relaxed); } }