Browse Source

Add a comment in election code.

Jing Yang 3 năm trước cách đây
mục cha
commit
b325a297ae
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      src/election.rs

+ 5 - 1
src/election.rs

@@ -159,7 +159,7 @@ impl<Command: ReplicableCommand> Raft<Command> {
                     cancel_handle.take().map(|c| c.send(()));
                 }
             }
-            // check the running signal before sleeping. We are holding the
+            // Check the running signal before sleeping. We are holding the
             // timer lock, so no one can change it. The kill() method will
             // not be able to notify this thread before `wait` is called.
             if !self.keep_running.load(Ordering::Relaxed) {
@@ -188,6 +188,10 @@ impl<Command: ReplicableCommand> Raft<Command> {
                     // Alarm has not fired yet. Continue to wait.
                 },
                 None => {
+                    // Nothing to do. Block here until the timer is reset.
+                    // We will not block here indefinitely at shutdown, since
+                    // we checked that keep_running is still true while holding
+                    // the election lock.
                     election.signal.wait(&mut guard);
                     // The timeout has changed, check again.
                     None