From 561b04cab0e359f231cffe93b9f0dbf58008bb6b Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 28 Jan 2026 10:15:31 +0100 Subject: [PATCH] feat(client): have the Client hold one task monitor --- crates/matrix-sdk/src/client/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 9cbdb5cc8..35e7a73d1 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -39,6 +39,7 @@ use matrix_sdk_base::{ WellKnownResponse, }, sync::{Notification, RoomUpdates}, + watchdog::TaskMonitor, }; use matrix_sdk_common::ttl_cache::TtlCache; #[cfg(feature = "e2e-encryption")] @@ -383,6 +384,9 @@ pub(crate) struct ClientInner { #[cfg(feature = "experimental-search")] /// Handler for [`RoomIndex`]'s of each room search_index: SearchIndex, + + /// A monitor for background tasks spawned by the client. + pub(crate) task_monitor: TaskMonitor, } impl ClientInner { @@ -449,6 +453,7 @@ impl ClientInner { #[cfg(feature = "experimental-search")] search_index: search_index_handler, thread_subscription_catchup, + task_monitor: TaskMonitor::new(), }; #[allow(clippy::let_and_return)] @@ -3312,6 +3317,12 @@ impl Client { media_store: media_store_size, }) } + + /// Get a reference to the client's task monitor, for spawning background + /// tasks. + pub(crate) fn task_monitor(&self) -> &TaskMonitor { + &self.inner.task_monitor + } } /// Contains the disk size of the different stores, if known. It won't be