diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 15 |
2 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 79d86f9b2..5ee218b6b 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -6,6 +6,7 @@ authors = ["Aleksey Kladov <[email protected]>"] | |||
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | rayon = "1.0.2" | 8 | rayon = "1.0.2" |
9 | threadpool = "1.7.1" | ||
9 | relative-path = "0.4.0" | 10 | relative-path = "0.4.0" |
10 | failure = "0.1.2" | 11 | failure = "0.1.2" |
11 | failure_derive = "0.1.2" | 12 | failure_derive = "0.1.2" |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 0e1878906..a01eeff88 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -9,7 +9,8 @@ use gen_lsp_server::{ | |||
9 | }; | 9 | }; |
10 | use languageserver_types::NumberOrString; | 10 | use languageserver_types::NumberOrString; |
11 | use ra_analysis::{Canceled, FileId, LibraryData}; | 11 | use ra_analysis::{Canceled, FileId, LibraryData}; |
12 | use rayon::{self, ThreadPool}; | 12 | use rayon; |
13 | use threadpool::ThreadPool; | ||
13 | use rustc_hash::FxHashSet; | 14 | use rustc_hash::FxHashSet; |
14 | use serde::{de::DeserializeOwned, Serialize}; | 15 | use serde::{de::DeserializeOwned, Serialize}; |
15 | use failure::{format_err, bail}; | 16 | use failure::{format_err, bail}; |
@@ -54,11 +55,7 @@ pub fn main_loop( | |||
54 | msg_receiver: &Receiver<RawMessage>, | 55 | msg_receiver: &Receiver<RawMessage>, |
55 | msg_sender: &Sender<RawMessage>, | 56 | msg_sender: &Sender<RawMessage>, |
56 | ) -> Result<()> { | 57 | ) -> Result<()> { |
57 | let pool = rayon::ThreadPoolBuilder::new() | 58 | let pool = ThreadPool::new(8); |
58 | .num_threads(4) | ||
59 | .panic_handler(|_| log::error!("thread panicked :(")) | ||
60 | .build() | ||
61 | .unwrap(); | ||
62 | let (task_sender, task_receiver) = unbounded::<Task>(); | 59 | let (task_sender, task_receiver) = unbounded::<Task>(); |
63 | let (fs_worker, fs_watcher) = vfs::roots_loader(); | 60 | let (fs_worker, fs_watcher) = vfs::roots_loader(); |
64 | let (ws_worker, ws_watcher) = workspace_loader(); | 61 | let (ws_worker, ws_watcher) = workspace_loader(); |
@@ -155,7 +152,7 @@ fn main_loop_inner( | |||
155 | } else { | 152 | } else { |
156 | let (files, resolver) = state.events_to_files(events); | 153 | let (files, resolver) = state.events_to_files(events); |
157 | let sender = libdata_sender.clone(); | 154 | let sender = libdata_sender.clone(); |
158 | pool.spawn(move || { | 155 | pool.execute(move || { |
159 | let start = ::std::time::Instant::now(); | 156 | let start = ::std::time::Instant::now(); |
160 | log::info!("indexing {} ... ", root.display()); | 157 | log::info!("indexing {} ... ", root.display()); |
161 | let data = LibraryData::prepare(files, resolver); | 158 | let data = LibraryData::prepare(files, resolver); |
@@ -402,7 +399,7 @@ impl<'a> PoolDispatcher<'a> { | |||
402 | Ok((id, params)) => { | 399 | Ok((id, params)) => { |
403 | let world = self.world.snapshot(); | 400 | let world = self.world.snapshot(); |
404 | let sender = self.sender.clone(); | 401 | let sender = self.sender.clone(); |
405 | self.pool.spawn(move || { | 402 | self.pool.execute(move || { |
406 | let resp = match f(world, params) { | 403 | let resp = match f(world, params) { |
407 | Ok(resp) => RawResponse::ok::<R>(id, &resp), | 404 | Ok(resp) => RawResponse::ok::<R>(id, &resp), |
408 | Err(e) => match e.downcast::<LspError>() { | 405 | Err(e) => match e.downcast::<LspError>() { |
@@ -452,7 +449,7 @@ fn update_file_notifications_on_threadpool( | |||
452 | sender: Sender<Task>, | 449 | sender: Sender<Task>, |
453 | subscriptions: Vec<FileId>, | 450 | subscriptions: Vec<FileId>, |
454 | ) { | 451 | ) { |
455 | pool.spawn(move || { | 452 | pool.execute(move || { |
456 | for file_id in subscriptions { | 453 | for file_id in subscriptions { |
457 | match handlers::publish_diagnostics(&world, file_id) { | 454 | match handlers::publish_diagnostics(&world, file_id) { |
458 | Err(e) => { | 455 | Err(e) => { |