Medium
Release store and acquire load around a non-atomic payload
Same structure as the relaxed-ordering example above, but now using release/acquire instead of relaxed. What does this program print?
main.cpp
std::atomic<bool> ready{false};
int data = 0;
void producer() {
data = 42;
ready.store(true, std::memory_order_release);
}
void consumer() {
while (!ready.load(std::memory_order_acquire)) {}
std::cout << data << std::endl;
}4 of 51 in Concurrency