gcc atomic read and writes
问题 I have a multithreaded application where I one producer thread(main) and multiple consumers. Now from main I want to have some sort of percentage of how far into the work the consumers are. Implementing a counter is easy as the work that is done a loop. However since this loop repeats a couple of thousands of times, maybe even more than a million times. I don`t want to mutex this part. So I went looking into some atomic options of writing to an int. As far as I understand I can use the