mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 23:31:24 +01:00
add constructor for lazy-loading service
This commit is contained in:
parent
3b28d0cfda
commit
a083ff9200
2 changed files with 11 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
collections::BTreeMap,
|
||||
sync::{Arc, Mutex as StdMutex, OnceLock},
|
||||
};
|
||||
|
||||
|
|
@ -88,10 +88,7 @@ impl Services {
|
|||
typing: rooms::edus::typing::Service::new(),
|
||||
},
|
||||
event_handler: rooms::event_handler::Service,
|
||||
lazy_loading: rooms::lazy_loading::Service {
|
||||
db,
|
||||
lazy_load_waiting: Mutex::new(HashMap::new()),
|
||||
},
|
||||
lazy_loading: rooms::lazy_loading::Service::new(db),
|
||||
metadata: db,
|
||||
outlier: db,
|
||||
pdu_metadata: rooms::pdu_metadata::Service {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ mod data;
|
|||
pub(crate) use data::Data;
|
||||
|
||||
pub(crate) struct Service {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
db: &'static dyn Data,
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub(crate) lazy_load_waiting: Mutex<
|
||||
lazy_load_waiting: Mutex<
|
||||
HashMap<
|
||||
(OwnedUserId, OwnedDeviceId, OwnedRoomId, PduCount),
|
||||
HashSet<OwnedUserId>,
|
||||
|
|
@ -23,6 +23,13 @@ pub(crate) struct Service {
|
|||
}
|
||||
|
||||
impl Service {
|
||||
pub(crate) fn new(db: &'static dyn Data) -> Self {
|
||||
Self {
|
||||
db,
|
||||
lazy_load_waiting: Mutex::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub(crate) fn lazy_load_was_sent_before(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue