Skip to content

Commit 4010994

Browse files
committed
Use default threadpool size
1 parent adda6db commit 4010994

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

crates/ra_lsp_server/src/main_loop.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ use crate::{
2929
Result, ServerConfig,
3030
};
3131

32-
const THREADPOOL_SIZE: usize = 8;
33-
const MAX_IN_FLIGHT_LIBS: usize = THREADPOOL_SIZE - 3;
34-
3532
#[derive(Debug)]
3633
pub struct LspError {
3734
pub code: i32,
@@ -168,7 +165,7 @@ pub fn main_loop(
168165
)
169166
};
170167

171-
let pool = ThreadPool::new(THREADPOOL_SIZE);
168+
let pool = ThreadPool::default();
172169
let (task_sender, task_receiver) = unbounded::<Task>();
173170
let (libdata_sender, libdata_receiver) = unbounded::<LibraryData>();
174171

@@ -371,7 +368,8 @@ fn loop_turn(
371368
loop_state.pending_libraries.extend(changes);
372369
}
373370

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
375373
&& !loop_state.pending_libraries.is_empty()
376374
{
377375
let (root, files) = loop_state.pending_libraries.pop().unwrap();

0 commit comments

Comments
 (0)