I have the following code being executed on a single thread (written in C++20):
std::atomic_bool is_ready{};
void SetReady() {
is_ready.store(true, std::memory_order_release);
is_ready.notify_all();
}
Other threads execute the text listed below:
void Wait() {
is_ready.wait(false, std::memory_order_acquire);
}
As I know, release memory order doesn't ensure that the operations located after it will not be reordered by a compiler. So, can I place notify_all() after store() with release memory order? Is it safe? Just I have some thoughts that store() may be sequenced before notify_all() and hence may not be reordered.