From 86c9de82313ccf79d0d8b9971fd96659f5d7e7aa Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 3 Aug 2021 18:46:36 -0400 Subject: [PATCH] Remove `grpc_core::WaitUntilWith{Deadline,Timeout}` (#26867) These functions are essentially unused. --- src/core/lib/gprpp/sync.h | 25 ++----------------------- test/cpp/end2end/xds_end2end_test.cc | 15 ++++++--------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/core/lib/gprpp/sync.h b/src/core/lib/gprpp/sync.h index f385883d1668e..d04e99740b7d6 100644 --- a/src/core/lib/gprpp/sync.h +++ b/src/core/lib/gprpp/sync.h @@ -19,10 +19,9 @@ #ifndef GRPC_CORE_LIB_GPRPP_SYNC_H #define GRPC_CORE_LIB_GPRPP_SYNC_H -#include +#include -#include -#include +#include #include #include @@ -152,26 +151,6 @@ static void WaitUntil(CondVar* cv, Mutex* mu, Predicate pred) { } } -// Returns true iff we timed-out -template -static bool WaitUntilWithTimeout(CondVar* cv, Mutex* mu, Predicate pred, - absl::Duration timeout) { - while (!pred()) { - if (cv->WaitWithTimeout(mu, timeout)) return true; - } - return false; -} - -// Returns true iff we timed-out -template -static bool WaitUntilWithDeadline(CondVar* cv, Mutex* mu, Predicate pred, - absl::Time deadline) { - while (!pred()) { - if (cv->WaitWithDeadline(mu, deadline)) return true; - } - return false; -} - // Deprecated. Prefer MutexLock class MutexLockForGprMu { public: diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index efbe259eebc25..c2f8821f15fab 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -792,20 +792,17 @@ class AdsServiceImpl : public std::enable_shared_from_this { response->DebugString().c_str()); stream->Write(response.value()); } - // If we didn't find anything to do, delay before the next loop - // iteration; otherwise, check whether we should exit and then - // immediately continue. - gpr_timespec deadline = - grpc_timeout_milliseconds_to_deadline(did_work ? 0 : 10); { grpc_core::MutexLock lock(&parent_->ads_mu_); - if (!grpc_core::WaitUntilWithDeadline( - &parent_->ads_cond_, &parent_->ads_mu_, - [this] { return parent_->ads_done_; }, - grpc_core::ToAbslTime(deadline))) { + if (parent_->ads_done_) { break; } } + // If we didn't find anything to do, delay before the next loop + // iteration; otherwise, check whether we should exit and then + // immediately continue. + gpr_sleep_until( + grpc_timeout_milliseconds_to_deadline(did_work ? 0 : 10)); } // Done with main loop. Clean up before returning. // Join reader thread.