diff --git a/src/context.rs b/src/context.rs index 9c2eb33e2..682d39f9c 100644 --- a/src/context.rs +++ b/src/context.rs @@ -24,7 +24,7 @@ use crate::key::{DcKey, SignedPublicKey}; use crate::login_param::LoginParam; use crate::message::{self, MessageState, MsgId}; use crate::quota::QuotaInfo; -use crate::scheduler::{IoPausedGuard, SchedulerState}; +use crate::scheduler::SchedulerState; use crate::sql::Sql; use crate::stock_str::StockStrings; use crate::timesmearing::SmearedTimestamp; @@ -409,16 +409,6 @@ impl Context { self.scheduler.restart(self).await; } - /// Pauses the IO scheduler. - /// - /// This temporarily pauses the IO scheduler and will make sure calls to - /// [`Context::start_io`] are no-ops while being paused. - /// - /// It is recommended to call [`IoPausedGuard::resume`] rather than simply dropping it. - pub(crate) async fn pause_io(&self) -> IoPausedGuard<'_> { - self.scheduler.pause(self).await - } - /// Indicate that the network likely has come back. pub async fn maybe_network(&self) { self.scheduler.maybe_network().await; diff --git a/src/imex.rs b/src/imex.rs index af02ba1d8..eeffbe231 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -87,7 +87,7 @@ pub async fn imex( let cancel = context.alloc_ongoing().await?; let res = { - let mut guard = context.pause_io().await; + let mut guard = context.scheduler.pause(context).await; let res = imex_inner(context, what, path, passphrase) .race(async { cancel.recv().await.ok(); diff --git a/src/scheduler.rs b/src/scheduler.rs index 5c2db37ea..9c9600d3a 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -87,12 +87,14 @@ impl SchedulerState { } } - /// Pauses the scheduler. + /// Pauses the IO scheduler. /// /// If it is currently running the scheduler will be stopped. When - /// [`IoPausedGuard::resume`] is called the scheduler is started again. If in the - /// meantime [`SchedulerState::start`] or [`SchedulerState::stop`] is called resume will - /// do the right thing. + /// [`IoPausedGuard::resume`] is called the scheduler is started again. + /// + /// If in the meantime [`SchedulerState::start`] or [`SchedulerState::stop`] is called + /// resume will do the right thing and restore the scheduler to the state requested by + /// the last call. pub(crate) async fn pause<'a>(&'_ self, context: &'a Context) -> IoPausedGuard<'a> { let mut inner = self.inner.write().await; inner.paused = true;