I am reading about std::condition_variable on http://ift.tt/1olYwuW and I don't understand this:
Even if the shared variable is atomic, it must be modified under the mutex in order to correctly publish the modification to the waiting thread.
Why a shared atomic variable is not properly published if it is not modified under mutex? How to understand this statement?
On another page http://ift.tt/1lXDALs there is a statement that seems to contradict to the the first statement:
If one thread writes to an atomic object while another thread reads from it, the behavior is well-defined (see memory model for details on data races)
Aucun commentaire:
Enregistrer un commentaire