diff options
author | Aleksey Kladov <[email protected]> | 2020-01-25 12:27:36 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-01-25 12:27:36 +0000 |
commit | 40109941db20180eb71b70c23c578fed5244bd74 (patch) | |
tree | 11dcbd9d584b74dd1aa5491d1bd8ae1a4cbd55ab | |
parent | adda6dbdf86afac34dc8710965de0018501bbe84 (diff) |
Use default threadpool size
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 83adf9711..315f4a4d6 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -29,9 +29,6 @@ use crate::{ | |||
29 | Result, ServerConfig, | 29 | Result, ServerConfig, |
30 | }; | 30 | }; |
31 | 31 | ||
32 | const THREADPOOL_SIZE: usize = 8; | ||
33 | const MAX_IN_FLIGHT_LIBS: usize = THREADPOOL_SIZE - 3; | ||
34 | |||
35 | #[derive(Debug)] | 32 | #[derive(Debug)] |
36 | pub struct LspError { | 33 | pub struct LspError { |
37 | pub code: i32, | 34 | pub code: i32, |
@@ -168,7 +165,7 @@ pub fn main_loop( | |||
168 | ) | 165 | ) |
169 | }; | 166 | }; |
170 | 167 | ||
171 | let pool = ThreadPool::new(THREADPOOL_SIZE); | 168 | let pool = ThreadPool::default(); |
172 | let (task_sender, task_receiver) = unbounded::<Task>(); | 169 | let (task_sender, task_receiver) = unbounded::<Task>(); |
173 | let (libdata_sender, libdata_receiver) = unbounded::<LibraryData>(); | 170 | let (libdata_sender, libdata_receiver) = unbounded::<LibraryData>(); |
174 | 171 | ||
@@ -371,7 +368,8 @@ fn loop_turn( | |||
371 | loop_state.pending_libraries.extend(changes); | 368 | loop_state.pending_libraries.extend(changes); |
372 | } | 369 | } |
373 | 370 | ||
374 | while loop_state.in_flight_libraries < MAX_IN_FLIGHT_LIBS | 371 | let max_in_flight_libs = pool.max_count().saturating_sub(2).max(1); |
372 | while loop_state.in_flight_libraries < max_in_flight_libs | ||
375 | && !loop_state.pending_libraries.is_empty() | 373 | && !loop_state.pending_libraries.is_empty() |
376 | { | 374 | { |
377 | let (root, files) = loop_state.pending_libraries.pop().unwrap(); | 375 | let (root, files) = loop_state.pending_libraries.pop().unwrap(); |