Is it ok to read a shared boolean flag without locking it when another thread may set it (at most once)?
It is never OK to read something possibly modified in a different thread without synchronization. What level of synchronization is needed depends on what you are actually reading. For primitive types, you should have a look at atomic reads, e.g. in the form of std::atomic<bool>. The reason synchronization is always needed is that the processors … Read more