std: use a queue-based Condvar
on NetBSD and other platforms by joboet · Pull Request #127578 · rust-lang/rust (original) (raw)
The problem is that every couple of months someone comes along and adds a completely new platform to std
. Understandably, not every target maintainer is well-versed in writing synchronization primitives, leading to bugs like #114581 on SGX. Actually, SGX is an interesting case, because the environment only provides thread parking, so there'll always be the need for some queue like this one. The idea behind this PR is that this implementation will be used as the default on every new target, unless they have a good reason not to, so that we only have to maintain one admittedly complex implementation instead of five.
There are simpler implementations that I could switch to, if desired (the NetBSD pthread_condvar
for example uses a stack of waiters and spins on contended access to it). It's just that making the shared implementation really good seemed like a good idea to me (it also might make it easier to convince people that they really shouldn't bring their own).