Let's say I have something like this:
bool signalled = false;
std::condition_variable cv;
void thread1() {
while (true) {
std::unique_lock l(mutex);
cv.wait_until(l, [] { return signalled; });
return;
}
}
void thread2...N() {
signalled = true;
cv.notify_all();
}
Is that considered thread-safe? The boolean may be set to true in many threads to interrupt thread1.
Edit: If not thread-safe I’m looking for a description of what the race condition is so I can better understand the underlying issue and fill in a knowledge gap.