Fix shared_cv deadlock

Was incorrect order of args for futex
This commit is contained in:
Ivan Chikish 2023-07-12 14:05:23 +03:00
parent 123321e2bc
commit de973e369f
5 changed files with 22 additions and 18 deletions

View file

@ -34,7 +34,7 @@ protected:
}
// Internal waiting function
void impl_wait(shared_mutex &mutex, unsigned _old,
void impl_wait(shared_mutex &mutex, unsigned _val,
std::uint64_t usec_timeout) noexcept;
// Try to notify up to _count threads
@ -44,13 +44,13 @@ public:
constexpr shared_cv() = default;
void wait(shared_mutex &mutex, std::uint64_t usec_timeout = -1) noexcept {
const unsigned _old = add_waiter();
if (!_old) {
const unsigned _val = add_waiter();
if (!_val) {
return;
}
mutex.unlock();
impl_wait(mutex, _old, usec_timeout);
impl_wait(mutex, _val, usec_timeout);
}
// Wake one thread