mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Move update_interval into IncrementableProgress
This commit is contained in:
parent
b002c45848
commit
58235d3709
1 changed files with 3 additions and 3 deletions
|
@ -21,10 +21,9 @@ pub(crate) struct IncrementableProgress<P> {
|
|||
progress_fn: Box<dyn FnMut(P, bool) -> bool>,
|
||||
count_map: Option<Box<dyn FnMut(usize) -> P>>,
|
||||
count: usize,
|
||||
update_interval: usize,
|
||||
}
|
||||
|
||||
const UPDATE_INTERVAL: usize = 17;
|
||||
|
||||
impl<P> IncrementableProgress<P> {
|
||||
/// `progress_fn: (progress, throttle) -> should_continue`
|
||||
pub(crate) fn new(progress_fn: impl 'static + FnMut(P, bool) -> bool) -> Self {
|
||||
|
@ -32,6 +31,7 @@ impl<P> IncrementableProgress<P> {
|
|||
progress_fn: Box::new(progress_fn),
|
||||
count_map: None,
|
||||
count: 0,
|
||||
update_interval: 17,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ impl<P> IncrementableProgress<P> {
|
|||
/// Must have called `set_count_map()` before calling this.
|
||||
pub(crate) fn increment(&mut self) -> Result<()> {
|
||||
self.count += 1;
|
||||
if self.count % UPDATE_INTERVAL != 0 {
|
||||
if self.count % self.update_interval != 0 {
|
||||
return Ok(());
|
||||
}
|
||||
let progress = self.mapped_progress()?;
|
||||
|
|
Loading…
Reference in a new issue