Browse Source

jobs/Timer: add set_interval()

lazy_fetch
Manos Pitsidianakis 11 months ago
parent
commit
2dfeb29b75
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 6
      src/components/utilities/widgets.rs
  2. 17
      src/jobs.rs

6
src/components/utilities/widgets.rs

@ -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

@ -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…
Cancel
Save