Say I have a class that contains a std::atomic_flag
as private member, exposed through a getter. Something like the following (pseudo-code):
class Thing
{
private:
std::atomic_flag ready = ATOMIC_FLAG_INIT;
public:
isReady()
{
return ready.test_and_set();
}
}
My naive question is: does querying the flag through a method turn it into a non-atomic operation, being a function call non-atomic (or is it?)? Should I make my ready
flag a public member and querying it directly?
Aucun commentaire:
Enregistrer un commentaire