refactor(job): refer to std:: only once

This change unifies how we refer to std::time::Duration across the module.
This commit is contained in:
Alexander Krotov
2019-12-21 04:22:29 +03:00
parent 5d9baa053a
commit 860f8a7906

View File

@@ -3,8 +3,7 @@
//! This module implements a job queue maintained in the SQLite database //! This module implements a job queue maintained in the SQLite database
//! and job types. //! and job types.
use std::time::Duration; use std::{fmt, time};
use std::*;
use deltachat_derive::{FromSql, ToSql}; use deltachat_derive::{FromSql, ToSql};
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
@@ -570,7 +569,7 @@ pub fn perform_smtp_idle(context: &Context) {
info!(context, "SMTP-idle ended.",); info!(context, "SMTP-idle ended.",);
} }
fn get_next_wakeup_time(context: &Context, thread: Thread) -> Duration { fn get_next_wakeup_time(context: &Context, thread: Thread) -> time::Duration {
let t: i64 = context let t: i64 = context
.sql .sql
.query_get_value( .query_get_value(
@@ -580,13 +579,13 @@ fn get_next_wakeup_time(context: &Context, thread: Thread) -> Duration {
) )
.unwrap_or_default(); .unwrap_or_default();
let mut wakeup_time = Duration::new(10 * 60, 0); let mut wakeup_time = time::Duration::new(10 * 60, 0);
let now = time(); let now = time();
if t > 0 { if t > 0 {
if t > now { if t > now {
wakeup_time = Duration::new((t - now) as u64, 0); wakeup_time = time::Duration::new((t - now) as u64, 0);
} else { } else {
wakeup_time = Duration::new(0, 0); wakeup_time = time::Duration::new(0, 0);
} }
} }
@@ -878,7 +877,7 @@ fn suspend_smtp_thread(context: &Context, suspend: bool) {
if !context.smtp_state.0.lock().unwrap().doing_jobs { if !context.smtp_state.0.lock().unwrap().doing_jobs {
return; return;
} }
std::thread::sleep(std::time::Duration::from_micros(300 * 1000)); std::thread::sleep(time::Duration::from_micros(300 * 1000));
} }
} }
} }