c++ - Qt example: no mutex lock when reading, why? -


i looking @ this example, , raises queston me: when looking @ this file mutex being used when accessing global variable m_abort when being changed. when run method reads it, nothing mutex @ all. why?

well, cannot see purpose of mutex @ all. both reading , writing m_abort can performed without mutex protection it's bool variable, , value changed atomically (at least on platforms). , if write not atomic , variable can have inconsistent value - can either false or true, , read true (since value written there true).


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -