mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
refactor: Replace Context::nosync flag with internal functions taking enum Sync (#4817)
This commit is contained in:
@@ -173,7 +173,6 @@ impl ContextBuilder {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Context {
|
||||
pub(crate) inner: Arc<InnerContext>,
|
||||
nosync: bool,
|
||||
}
|
||||
|
||||
impl Deref for Context {
|
||||
@@ -393,34 +392,11 @@ impl Context {
|
||||
|
||||
let ctx = Context {
|
||||
inner: Arc::new(inner),
|
||||
nosync: false,
|
||||
};
|
||||
|
||||
Ok(ctx)
|
||||
}
|
||||
|
||||
/// Returns a `Context` in which sending sync messages must be skipped. `Self::unwrap_nosync()`
|
||||
/// should be used to check this.
|
||||
pub(crate) fn nosync(&self) -> Self {
|
||||
Self {
|
||||
inner: self.inner.clone(),
|
||||
nosync: true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if sending sync messages must be skipped. Returns the original context and the result
|
||||
/// of the check. If it's `true`, calls to [`Self::add_sync_item()`] mustn't be done to prevent
|
||||
/// extra/recursive synchronisation.
|
||||
pub(crate) fn unwrap_nosync(&self) -> (Self, bool) {
|
||||
(
|
||||
Self {
|
||||
inner: self.inner.clone(),
|
||||
nosync: false,
|
||||
},
|
||||
self.nosync,
|
||||
)
|
||||
}
|
||||
|
||||
/// Starts the IO scheduler.
|
||||
pub async fn start_io(&mut self) {
|
||||
if !self.is_configured().await.unwrap_or_default() {
|
||||
|
||||
Reference in New Issue
Block a user