I'm incrementing/decrementing boost::detail::atomic_count in multiple threads.
Wonder if this practice is ok or if I need a lock around it(th开发者_开发百科en I could just use regular int variable)?Thank you.
The entire purpose of an atomic variable is to be lock-free* and thread-safe.
So yes, it's perfectly safe; no, you don't need a lock.
*That is, the "lock" is done at hardware level. Are you using something without understanding it first? :)
精彩评论