Skip to content

Commit

Permalink
Remove grpc_core::WaitUntilWith{Deadline,Timeout} (grpc#26867)
Browse files Browse the repository at this point in the history
These functions are essentially unused.
  • Loading branch information
tamird authored Aug 3, 2021
1 parent aeef9aa commit 86c9de8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
25 changes: 2 additions & 23 deletions src/core/lib/gprpp/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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:
Expand Down
15 changes: 6 additions & 9 deletions test/cpp/end2end/xds_end2end_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 86c9de8

Please sign in to comment.