Fixup shared_mutex::lock_forced

This commit is contained in:
Ivan Chikish 2023-07-23 06:01:56 +03:00
parent a7d255d401
commit 630213afb6

View file

@ -152,7 +152,7 @@ void shared_mutex::impl_lock_upgrade() {
}
bool shared_mutex::lock_forced(int count) {
if (count == 0)
std::abort();
return false;
if (count > 0) {
// Lock
return atomic_op(m_value, [&](unsigned &v) {
@ -172,12 +172,8 @@ bool shared_mutex::lock_forced(int count) {
});
}
// Unlock
const unsigned value = m_value.fetch_add(c_one * count);
if (value != c_one) [[unlikely]] {
impl_unlock(value);
}
return false;
// Remove waiters
m_value.fetch_add(c_one * count);
return true;
}
} // namespace orbis::utils