New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util/timer: introduce steady timer #4060
Conversation
Steady timer is used to create futures that is notified after a given duration. It's called steady because it won't be affected by the time adjustment. This is important for raftstore as the lease mechanism is based on a steady time. Signed-off-by: Jay Lee <busyjaylee@gmail.com>
src/util/timer.rs
Outdated
let clock = SteadyClock::default(); | ||
let clock_ = clock.clone(); | ||
Builder::new() | ||
.name(thd_name!("steady timer")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename to steady-timer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it can also take time-monitor
thread's job checks if time jumps back, but it can be left for future work.
src/util/timer.rs
Outdated
} | ||
|
||
impl SteadyTimer { | ||
/// Create a delay future that will be notified after the given duration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Create a delay future that will be notified after the given duration. | |
/// Creates a delay future that will be notified after the given duration. |
|
||
impl SteadyTimer { | ||
/// Create a delay future that will be notified after the given duration. | ||
pub fn delay(&self, dur: Duration) -> Delay { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do every leader need to create a Delay
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Why not keep the old style of lease renewal that renew lease by propoals? |
It's for tick scheduling instead of lease. |
Signed-off-by: Jay Lee <busyjaylee@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-integration-tests |
Steady timer is used to create futures that is notified after a given duration. It's called steady because it won't be affected by the time adjustment. This is important for raftstore as the lease mechanism is based on a steady time.
Steady timer is used to create futures that is notified after a given
duration. It's called steady because it won't be affected by the time
adjustment. This is important for raftstore as the lease mechanism is
based on a steady time.