mardi 27 janvier 2015

Are Iterators right hand value assignment operations atomic?

I'm currently dealing with a data race somewhere in my code and can't really seem to pinpoint where exactly this is occurring. What I mean by right hand assignment is



Iterator iter = destination; //assign local iterator from dest iterator


for context, the function splits up a data set into chunks and executes each chunk in parallel. Each chunk will execute a lambda function, and the chunks are not guaranteed to execute in any order. They may all be ran at the same time or some before others. The beginning of the lambda has the line above, so:



[dest](Data &data, Iterator part_begin, std::size_t part_size) mutable
{
Iterator iter = dest;
std::advance(iter, get<0>(data)); //use this iter for the algorithm
// ...
// ...
}


Is this a safe operation to do? I know iterators value accessing is not an atomic operation such as int is, so I'm uncertain if this is valid.


Aucun commentaire:

Enregistrer un commentaire