Given:
class foo {
std::atomic<bool> a;
std::atomic<bool> b;
}
Is there any difference between:
void foo::reset() {
a = false;
b = false;
}
And:
void foo::reset() {
a = b = false;
}
Namely, in the second case, can it happen that after b is assigned false, another thread set b to true before b is read to assign its value to a, so that at the end of the instruction the value of a is true?
(This would also imply that the letter version is seemingly less efficient)
Aucun commentaire:
Enregistrer un commentaire