Fix CondVar::TimedWait for Windows (#12815)

Summary:
Based on https://github.com/microsoft/STL/issues/369
They fixed the issue in `std::condition_variable_any` but not in `std::condition_variable`, which is currently used in rocksdb repo. So we need to implement the work around regardless of `_MSVC_STL_UPDATE`.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12815

Reviewed By: cbi42

Differential Revision: D59493690

Pulled By: ajkr

fbshipit-source-id: ad0fc9ef9f2357347d21e271c2f1d0a3a97d89be
This commit is contained in:
Jeffery 2024-07-08 21:38:21 -07:00 committed by Facebook GitHub Bot
parent a97a1f3247
commit 62b62cf135
1 changed files with 3 additions and 2 deletions

View File

@ -101,8 +101,9 @@ bool CondVar::TimedWait(uint64_t abs_time_us) {
std::unique_lock<std::mutex> lk(mu_->getLock(), std::adopt_lock); std::unique_lock<std::mutex> lk(mu_->getLock(), std::adopt_lock);
// Work around https://github.com/microsoft/STL/issues/369 // Work around https://github.com/microsoft/STL/issues/369
#if defined(_MSC_VER) && \ // std::condition_variable_any::wait_for had a fix, but
(!defined(_MSVC_STL_UPDATE) || _MSVC_STL_UPDATE < 202008L) // std::condition_variable still doesn't have a fix in STL yet
#if defined(_MSC_VER)
if (relTimeUs == std::chrono::microseconds::zero()) { if (relTimeUs == std::chrono::microseconds::zero()) {
lk.unlock(); lk.unlock();
lk.lock(); lk.lock();