jobs/Timer: add set_interval()
parent
63d2fb93f4
commit
2dfeb29b75
|
@ -1343,12 +1343,6 @@ impl ProgressSpinner {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for ProgressSpinner {
|
||||
fn drop(&mut self) {
|
||||
self.stop();
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ProgressSpinner {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "progress bar")
|
||||
|
|
17
src/jobs.rs
17
src/jobs.rs
|
@ -138,6 +138,16 @@ impl Timer {
|
|||
pub fn disable(&self) {
|
||||
self.job_executor.disable_timer(self.id);
|
||||
}
|
||||
|
||||
pub fn set_interval(&self, new_val: Duration) {
|
||||
self.job_executor.set_interval(self.id, new_val);
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Timer {
|
||||
fn drop(&mut self) {
|
||||
self.disable();
|
||||
}
|
||||
}
|
||||
|
||||
impl JobExecutor {
|
||||
|
@ -329,6 +339,13 @@ impl JobExecutor {
|
|||
timer.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
fn set_interval(&self, id: Uuid, new_val: Duration) {
|
||||
let mut timers_lck = self.timers.lock().unwrap();
|
||||
if let Some(timer) = timers_lck.get_mut(&id) {
|
||||
timer.interval = new_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type JobChannel<T> = oneshot::Receiver<T>;
|
||||
|
|
Loading…
Reference in New Issue