ReactiveX / RxCpp

Reactive Extensions for C++
Apache License 2.0
3.03k stars 390 forks source link

Corrected rare deadlock condition on observable.as_blocking().subscribe() #543

Closed quetzalcoatl closed 4 years ago

quetzalcoatl commented 4 years ago

Previously flag was set after pinging the condition variable, so waiting thread could woke up before the flag was set, and then the thread entered sleep again since condition was not met (yet). The problem was, nothing ever woke this thread as the "cs" was already spent. On some platforms the threads could actually wake up due to https://en.wikipedia.org/wiki/Spurious_wakeup but that's not guaranteed to ever happen.