3 ms·
The right solution when using atomics is to use a binary semaphore instead of condition variables, and implement the wait as if (!cond) { sem.try_acq
by bonzini 3y ago
The right solution when using atomics is to use a binary semaphore instead of condition variables, and implement the wait as
if (!cond) {
sem.try_acquire();
if (!cond) {
sem.acquire();
}
}
Though this only works if there is a single waiter.