Simple question, but I did not find an answer.
Given
struct Foo {
std::atomic_int i;
void setMin(int j);
}
How do I set i to std::min(i,j)? If there is a race between two calls setMin(j1) and setMin(j2), the result should be std::min(i,j1,j2), and naturally the same for more than 2 concurrent calls.
I found Atomic Minimum on x86 using OpenMP which says "[C++11] does not have support for atomic minimum. "