This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit a27de78de2de7b15e18ff0e9e6a4b3e57c398ac7
Author: Alexey Serbin <[email protected]>
AuthorDate: Sun Feb 2 21:11:25 2020 -0800

    [consensus] cleanup on TimeManager
    
    A tiny cleanup:
      * removed outdated TODO TimeManager::WaitUntilSafe()
      * removed questionable PREDICT_FALSE() and its extra 'if ()' scope
    
    I also thought of replacing std::vector with std::deque as the container
    for TimeManager::waiters_, but I'm not sure it's worth it given the
    expected number of elements in there.
    
    Change-Id: I1315e058b4a8e0518c96fad6454aeb4d0a46b2e6
    Reviewed-on: http://gerrit.cloudera.org:8080/15150
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <[email protected]>
---
 src/kudu/consensus/time_manager.cc | 18 ++++++++----------
 src/kudu/consensus/time_manager.h  |  5 +----
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/kudu/consensus/time_manager.cc 
b/src/kudu/consensus/time_manager.cc
index 5428e51..e5cc887 100644
--- a/src/kudu/consensus/time_manager.cc
+++ b/src/kudu/consensus/time_manager.cc
@@ -265,17 +265,15 @@ void 
TimeManager::AdvanceSafeTimeAndWakeUpWaitersUnlocked(Timestamp safe_time) {
   last_safe_ts_ = safe_time;
   last_advanced_safe_time_ = MonoTime::Now();
 
-  if (PREDICT_FALSE(!waiters_.empty())) {
-    auto iter = waiters_.begin();
-    while (iter != waiters_.end()) {
-      WaitingState* waiter = *iter;
-      if (IsTimestampSafeUnlocked(waiter->timestamp)) {
-        iter = waiters_.erase(iter);
-        waiter->latch->CountDown();
-        continue;
-      }
-      iter++;
+  auto iter = waiters_.begin();
+  while (iter != waiters_.end()) {
+    WaitingState* waiter = *iter;
+    if (IsTimestampSafeUnlocked(waiter->timestamp)) {
+      iter = waiters_.erase(iter);
+      waiter->latch->CountDown();
+      continue;
     }
+    ++iter;
   }
 }
 
diff --git a/src/kudu/consensus/time_manager.h 
b/src/kudu/consensus/time_manager.h
index 46fa63c..e272fa7 100644
--- a/src/kudu/consensus/time_manager.h
+++ b/src/kudu/consensus/time_manager.h
@@ -120,9 +120,6 @@ class TimeManager {
   // Returns Status::OK() if it safe time advanced past 'timestamp' before 
'deadline'
   // Returns Status::TimeOut() if deadline elapsed without safe time moving 
enough.
   // Returns Status::ServiceUnavailable() is the request should be retried 
somewhere else.
-  //
-  // TODO(KUDU-1127) make this return another status if safe time is too far 
back in the past
-  // or hasn't moved in a long time.
   Status WaitUntilSafe(Timestamp timestamp, const MonoTime& deadline);
 
   // Returns the current safe time.
@@ -196,7 +193,7 @@ class TimeManager {
   mutable simple_spinlock lock_;
 
   // Vector of waiters to be notified when the safe time advances.
-  mutable std::vector<WaitingState*> waiters_;
+  std::vector<WaitingState*> waiters_;
 
   // The last serial timestamp that was assigned.
   Timestamp last_serial_ts_assigned_;

Reply via email to