Merge "Revert "Update to handle spurious wake up in conditional variable""

This commit is contained in:
Cong Lin
2023-03-10 01:29:49 +00:00
committed by Android (Google) Code Review

View File

@@ -44,12 +44,6 @@ using video_widevine::ProvisioningResponse;
using wvcdm::kLevel3;
using wvcdm::kLevelDefault;
using namespace std;
using namespace std::chrono;
#define GET_TIME() \
((duration_cast<milliseconds>(system_clock::now().time_since_epoch())) \
.count())
#define TIMEOUT_IN_MILLISECONDS 2 * 60 * 1000 // 2 minutes
namespace {
@@ -538,16 +532,7 @@ class WatchDog {
{
std::unique_lock<std::mutex> lock(mutex_);
if (running_) {
bool waitStatus = false;
time_t time = GET_TIME();
do {
waitStatus = condition_.wait_for(
lock, std::chrono::milliseconds(TIMEOUT_IN_MILLISECONDS),
[time, this]() {
return ((GET_TIME() > time + TIMEOUT_IN_MILLISECONDS) |
(!running_));
});
} while (waitStatus != true);
condition_.wait_for(lock, std::chrono::minutes(2));
}
if (running_) {
gave_up_ = true;