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
Post a Comment