Remove `grpc_core::WaitUntilWith{Deadline,Timeout}` (#26867)

These functions are essentially unused.
pull/26866/head
Tamir Duberstein 4 years ago committed by GitHub
parent aeef9aa8cf
commit 86c9de8231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      src/core/lib/gprpp/sync.h
  2. 15
      test/cpp/end2end/xds_end2end_test.cc

@ -19,10 +19,9 @@
#ifndef GRPC_CORE_LIB_GPRPP_SYNC_H
#define GRPC_CORE_LIB_GPRPP_SYNC_H
#include <grpc/impl/codegen/port_platform.h>
#include <grpc/support/port_platform.h>
#include <grpc/impl/codegen/log.h>
#include <grpc/impl/codegen/sync.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@ -152,26 +151,6 @@ static void WaitUntil(CondVar* cv, Mutex* mu, Predicate pred) {
}
}
// Returns true iff we timed-out
template <typename Predicate>
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 <typename Predicate>
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:

@ -792,20 +792,17 @@ class AdsServiceImpl : public std::enable_shared_from_this<AdsServiceImpl> {
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.

Loading…
Cancel
Save