I've known that std::atomic_flag
is guaranteed to be lock free whereas other atomic stuffs, such as std::atomic<int>
, std::atomic<bool>
are not, meaning that they may be generated with lock.
My question is why there is only one thing std::atomic_flag
is lock free and others may be not? Why don't we force to use lock free to generate things like std::atomic<bool>
? Is there some technique reason?