I wasn't aware of the std::atomic variables but was aware about the std::mutex (wierd right!) provided by the standard. However one thing caught my eye. There are two seemingly-same(to me) atomic types provided by the standard, listed below -
-
std::atomic bool type- Listed here - http://ift.tt/1lXDALs -
std::atomic_flag type- http://ift.tt/1qjt9jR
Also it is mentioned with the example of std::atomic_flag type -
std::atomic_flag is an atomic boolean type. Unlike all specializations of std::atomic, it is guaranteed to be lock-free. Unlike std::atomic, std::atomic_flag does not provide load or store operations.
which I fail to understand. is std::atomic bool type not guranteed to be lock-free? then it's not atomic or what?
So what's the difference b/w two and when should I use which?
Aucun commentaire:
Enregistrer un commentaire