diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/server/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/server/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/server/src/main_loop/mod.rs | 14 |
3 files changed, 10 insertions, 8 deletions
diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index cb96929c6..9aeea9a9b 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml | |||
@@ -4,6 +4,7 @@ version = "0.1.0" | |||
4 | authors = ["Aleksey Kladov <[email protected]>"] | 4 | authors = ["Aleksey Kladov <[email protected]>"] |
5 | 5 | ||
6 | [dependencies] | 6 | [dependencies] |
7 | rayon = "1.0.2" | ||
7 | relative-path = "0.3.7" | 8 | relative-path = "0.3.7" |
8 | failure = "0.1.2" | 9 | failure = "0.1.2" |
9 | serde_json = "1.0.24" | 10 | serde_json = "1.0.24" |
@@ -11,7 +12,6 @@ serde = "1.0.71" | |||
11 | serde_derive = "1.0.71" | 12 | serde_derive = "1.0.71" |
12 | drop_bomb = "0.1.0" | 13 | drop_bomb = "0.1.0" |
13 | crossbeam-channel = "0.2.4" | 14 | crossbeam-channel = "0.2.4" |
14 | threadpool = "1.7.1" | ||
15 | flexi_logger = "0.9.1" | 15 | flexi_logger = "0.9.1" |
16 | log = "0.4.3" | 16 | log = "0.4.3" |
17 | url_serde = "0.2.0" | 17 | url_serde = "0.2.0" |
diff --git a/crates/server/src/lib.rs b/crates/server/src/lib.rs index d874ecf84..9e094af10 100644 --- a/crates/server/src/lib.rs +++ b/crates/server/src/lib.rs | |||
@@ -7,7 +7,7 @@ extern crate serde_json; | |||
7 | extern crate languageserver_types; | 7 | extern crate languageserver_types; |
8 | #[macro_use] | 8 | #[macro_use] |
9 | extern crate crossbeam_channel; | 9 | extern crate crossbeam_channel; |
10 | extern crate threadpool; | 10 | extern crate rayon; |
11 | #[macro_use] | 11 | #[macro_use] |
12 | extern crate log; | 12 | extern crate log; |
13 | extern crate drop_bomb; | 13 | extern crate drop_bomb; |
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs index 52e3b661d..52f2a8977 100644 --- a/crates/server/src/main_loop/mod.rs +++ b/crates/server/src/main_loop/mod.rs | |||
@@ -6,9 +6,9 @@ use std::{ | |||
6 | collections::{HashMap}, | 6 | collections::{HashMap}, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use threadpool::ThreadPool; | ||
10 | use serde::{Serialize, de::DeserializeOwned}; | 9 | use serde::{Serialize, de::DeserializeOwned}; |
11 | use crossbeam_channel::{unbounded, Sender, Receiver}; | 10 | use crossbeam_channel::{unbounded, Sender, Receiver}; |
11 | use rayon::{self, ThreadPool}; | ||
12 | use languageserver_types::{NumberOrString}; | 12 | use languageserver_types::{NumberOrString}; |
13 | use libanalysis::{FileId, JobHandle, JobToken, LibraryData}; | 13 | use libanalysis::{FileId, JobHandle, JobToken, LibraryData}; |
14 | use gen_lsp_server::{ | 14 | use gen_lsp_server::{ |
@@ -37,7 +37,9 @@ pub fn main_loop( | |||
37 | msg_receriver: &mut Receiver<RawMessage>, | 37 | msg_receriver: &mut Receiver<RawMessage>, |
38 | msg_sender: &mut Sender<RawMessage>, | 38 | msg_sender: &mut Sender<RawMessage>, |
39 | ) -> Result<()> { | 39 | ) -> Result<()> { |
40 | let pool = ThreadPool::new(4); | 40 | let pool = rayon::ThreadPoolBuilder::new() |
41 | .num_threads(4).build() | ||
42 | .unwrap(); | ||
41 | let (task_sender, task_receiver) = unbounded::<Task>(); | 43 | let (task_sender, task_receiver) = unbounded::<Task>(); |
42 | let (fs_sender, fs_receiver, fs_watcher) = vfs::roots_loader(); | 44 | let (fs_sender, fs_receiver, fs_watcher) = vfs::roots_loader(); |
43 | let (ws_sender, ws_receiver, ws_watcher) = workspace_loader(); | 45 | let (ws_sender, ws_receiver, ws_watcher) = workspace_loader(); |
@@ -68,7 +70,7 @@ pub fn main_loop( | |||
68 | task_receiver.for_each(|task| on_task(task, msg_sender, &mut pending_requests)); | 70 | task_receiver.for_each(|task| on_task(task, msg_sender, &mut pending_requests)); |
69 | info!("...tasks have finished"); | 71 | info!("...tasks have finished"); |
70 | info!("joining threadpool..."); | 72 | info!("joining threadpool..."); |
71 | pool.join(); | 73 | drop(pool); |
72 | info!("...threadpool has finished"); | 74 | info!("...threadpool has finished"); |
73 | 75 | ||
74 | let fs_res = fs_watcher.stop(); | 76 | let fs_res = fs_watcher.stop(); |
@@ -136,7 +138,7 @@ fn main_loop_inner( | |||
136 | } else { | 138 | } else { |
137 | let files = state.events_to_files(events); | 139 | let files = state.events_to_files(events); |
138 | let sender = libdata_sender.clone(); | 140 | let sender = libdata_sender.clone(); |
139 | pool.execute(move || { | 141 | pool.spawn(move || { |
140 | let start = ::std::time::Instant::now(); | 142 | let start = ::std::time::Instant::now(); |
141 | info!("indexing {} ... ", root.display()); | 143 | info!("indexing {} ... ", root.display()); |
142 | let data = LibraryData::prepare(files); | 144 | let data = LibraryData::prepare(files); |
@@ -354,7 +356,7 @@ impl<'a> PoolDispatcher<'a> { | |||
354 | let (handle, token) = JobHandle::new(); | 356 | let (handle, token) = JobHandle::new(); |
355 | let world = self.world.snapshot(); | 357 | let world = self.world.snapshot(); |
356 | let sender = self.sender.clone(); | 358 | let sender = self.sender.clone(); |
357 | self.pool.execute(move || { | 359 | self.pool.spawn(move || { |
358 | let resp = match f(world, params, token) { | 360 | let resp = match f(world, params, token) { |
359 | Ok(resp) => RawResponse::ok::<R>(id, &resp), | 361 | Ok(resp) => RawResponse::ok::<R>(id, &resp), |
360 | Err(e) => RawResponse::err(id, ErrorCode::InternalError as i32, e.to_string()), | 362 | Err(e) => RawResponse::err(id, ErrorCode::InternalError as i32, e.to_string()), |
@@ -386,7 +388,7 @@ fn update_file_notifications_on_threadpool( | |||
386 | sender: Sender<Task>, | 388 | sender: Sender<Task>, |
387 | subscriptions: Vec<FileId>, | 389 | subscriptions: Vec<FileId>, |
388 | ) { | 390 | ) { |
389 | pool.execute(move || { | 391 | pool.spawn(move || { |
390 | for file_id in subscriptions { | 392 | for file_id in subscriptions { |
391 | match handlers::publish_diagnostics(world.clone(), file_id) { | 393 | match handlers::publish_diagnostics(world.clone(), file_id) { |
392 | Err(e) => { | 394 | Err(e) => { |