From 0de64f4f712a3de1f4c320e2182f9cf82164231c Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sun, 21 Apr 2024 19:09:16 +0800 Subject: [PATCH] chore: enable multiple thread of collab-rt crate (#484) --- Cargo.toml | 2 +- libs/client-api/src/collab_sync/collab_stream.rs | 1 - libs/collab-rt/Cargo.toml | 2 +- libs/collab-rt/src/rt_server.rs | 6 +++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cc4fa059..27a34e29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -191,7 +191,7 @@ dashmap = "5.5.3" futures = "0.3.30" async-stream = "0.3.5" reqwest = "0.11.27" -collab-rt = { path = "libs/collab-rt" } +collab-rt = { path = "libs/collab-rt", features = ["collab-rt-multi-thread"] } lazy_static = "1.4.0" tonic = "0.11" prost = "0.12" diff --git a/libs/client-api/src/collab_sync/collab_stream.rs b/libs/client-api/src/collab_sync/collab_stream.rs index 70dc2853..8353416c 100644 --- a/libs/client-api/src/collab_sync/collab_stream.rs +++ b/libs/client-api/src/collab_sync/collab_stream.rs @@ -226,7 +226,6 @@ where for yrs_message in reader { let msg = yrs_message?; let is_server_sync_step_1 = matches!(msg, Message::Sync(SyncMessage::SyncStep1(_))); - if let Some(return_payload) = handle_message_follow_protocol(&message_origin, &ClientSyncProtocol, &mut collab, msg)? { diff --git a/libs/collab-rt/Cargo.toml b/libs/collab-rt/Cargo.toml index a3fa8fd9..5b9c6e56 100644 --- a/libs/collab-rt/Cargo.toml +++ b/libs/collab-rt/Cargo.toml @@ -45,4 +45,4 @@ lazy_static = "1.4.0" rand = "0.8.5" [features] -multi-thread = [] \ No newline at end of file +collab-rt-multi-thread = [] diff --git a/libs/collab-rt/src/rt_server.rs b/libs/collab-rt/src/rt_server.rs index 766bf980..f51086e9 100644 --- a/libs/collab-rt/src/rt_server.rs +++ b/libs/collab-rt/src/rt_server.rs @@ -51,7 +51,7 @@ where metrics: Arc, command_recv: RTCommandReceiver, ) -> Result { - if cfg!(feature = "multi-thread") { + if cfg!(feature = "collab-rt-multi-thread") { info!("CollaborationServer with multi-thread feature enabled"); } @@ -249,7 +249,7 @@ pub fn default_tokio_runtime() -> io::Result { /// task execution confines all tasks to the same thread, attributable to the actor's reliance on a /// single-threaded Tokio runtime. To circumvent this limitation and enable task execution across /// multiple threads, we've incorporated a multi-thread feature. -#[cfg(feature = "multi-thread")] +#[cfg(feature = "collab-rt-multi-thread")] pub(crate) fn rt_spawn(future: T) -> tokio::task::JoinHandle where T: Future + Send + 'static, @@ -258,7 +258,7 @@ where COLLAB_RUNTIME.spawn(future) } -#[cfg(not(feature = "multi-thread"))] +#[cfg(not(feature = "collab-rt-multi-thread"))] pub(crate) fn rt_spawn(future: T) -> tokio::task::JoinHandle where T: Future + 'static,