chore: enable multiple threads (#753)

This commit is contained in:
Nathan.fooo 2024-08-27 11:15:54 +08:00 committed by GitHub
parent c182ad7099
commit cbb9adc29d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 11 deletions

View File

@ -23,6 +23,7 @@ use crate::group::cmd::{GroupCommand, GroupCommandRunner, GroupCommandSender};
use crate::group::manager::GroupManager;
use crate::indexer::IndexerProvider;
use crate::metrics::CollabMetricsCalculate;
use crate::rt_server::collaboration_runtime::COLLAB_RUNTIME;
use crate::state::RedisConnectionManager;
use crate::{spawn_metrics, CollabRealtimeMetrics, RealtimeClientWebsocketSink};
@ -199,7 +200,7 @@ where
let object_id = entry.key().clone();
let clone_notify = notify.clone();
tokio::spawn(runner.run(object_id, clone_notify));
COLLAB_RUNTIME.spawn(runner.run(object_id, clone_notify));
entry.insert(new_sender.clone());
// wait for the runner to be ready to handle the message.
@ -287,9 +288,7 @@ fn spawn_period_check_inactive_group<S, AC>(
/// multiple threads, we've incorporated a multi-thread feature.
///
/// When appflowy-collaborate is deployed as a standalone service, we can use tokio multi-thread.
#[cfg(feature = "collab-rt-multi-thread")]
mod collaboration_runtime {
use std::future::Future;
use std::io;
use lazy_static::lazy_static;
@ -307,12 +306,4 @@ mod collaboration_runtime {
.enable_time()
.build()
}
pub(crate) fn spawn<T>(future: T) -> tokio::task::JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
COLLAB_RUNTIME.spawn(future)
}
}