forked from sofastack/sofa-jraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reset timer instead of
start()
when stepDown (sofastack#408)
* Fix * Refine * address comment * Fix
- Loading branch information
1 parent
74684dc
commit 6b66aa6
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,6 +151,28 @@ public void start() { | |
} | ||
} | ||
|
||
/** | ||
* Restart the timer. | ||
* It will be started if it's stopped, and it will be restarted if it's running. | ||
* | ||
* @author Qing Wang ([email protected]) | ||
* | ||
* 2020-Mar-26 20:38:37 PM | ||
*/ | ||
public void restart() { | ||
this.lock.lock(); | ||
try { | ||
if (this.destroyed) { | ||
return; | ||
} | ||
this.stopped = false; | ||
this.running = true; | ||
schedule(); | ||
} finally { | ||
this.lock.unlock(); | ||
} | ||
} | ||
|
||
private void schedule() { | ||
if (this.timeout != null) { | ||
this.timeout.cancel(); | ||
|