I have similar code in my project:
class foo
{
private:
mutable std::atomic_bool flag;
int a, b;
public:
int GetA() const
{
if ( flag )
//... some сode here
else
//...
}
int GetB() const
{
//...
flag = true;
//...
}
}
The helgrind tool says, that there is possible data race on flag variable, when GetA and GetB methods are called from different threads. I tried to use boost::atomic with similar result. Are any variants to fix it but suppressing?
Aucun commentaire:
Enregistrer un commentaire