mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 20:26:52 +00:00
refactor(service): Use SyncRwLock and SyncMutex for in-memory services
Convert in-memory data structures in appservice, rooms::typing, and sync wakers to use SyncRwLock and SyncMutex. Drop appservice locks before making outbound network requests in room alias queries and federation invites.
This commit is contained in:
20 files changed
+126
-160
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use conduwuit::{Err, Result, checked};
|
||||
use conduwuit::{Err, Result, checked, utils::ReadyExt};
|
||||
use futures::{FutureExt, StreamExt, TryFutureExt};
|
||||
|
||||
impl crate::Context<'_> {
|
||||
@@ -49,7 +49,6 @@ impl crate::Context<'_> {
|
||||
.services
|
||||
.appservice
|
||||
.get_registration(&appservice_identifier)
|
||||
.await
|
||||
{
|
||||
| None => return Err!("Appservice does not exist."),
|
||||
| Some(config) => {
|
||||
@@ -78,12 +77,11 @@ impl crate::Context<'_> {
|
||||
self.services
|
||||
.users
|
||||
.stream_local_users()
|
||||
.filter_map(async |user_id| {
|
||||
if self.services.appservice.is_user_id(&user_id).await {
|
||||
Some(user_id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.ready_filter_map(|user_id| {
|
||||
self.services
|
||||
.appservice
|
||||
.is_user_id(&user_id)
|
||||
.then_some(user_id)
|
||||
})
|
||||
.for_each(async |user_id| {
|
||||
self.services
|
||||
|
||||
@@ -24,7 +24,7 @@ pub(super) async fn process(subcommand: AppserviceCommand, context: &Context<'_>
|
||||
match subcommand {
|
||||
| AppserviceCommand::GetRegistration { appservice_id } => {
|
||||
let timer = tokio::time::Instant::now();
|
||||
let results = services.appservice.get_registration(&appservice_id).await;
|
||||
let results = services.appservice.get_registration(&appservice_id);
|
||||
|
||||
let query_time = timer.elapsed();
|
||||
|
||||
|
||||
Reference in new issue
Block a user