From 78e17f65cfa0013ea51d94f0142ca6d4bcc5d088 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 May 2019 20:52:09 +0300 Subject: use sync queries for join lines and friends --- crates/ra_lsp_server/src/main_loop.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 8a7c53d2c..452499497 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -315,14 +315,18 @@ fn on_request( request_received, }; pool_dispatcher - .on_sync::(|state, ()| Ok(state.collect_garbage()))? + .on_sync::(|s, ()| Ok(s.collect_garbage()))? + .on_sync::(|s, p| handlers::handle_join_lines(s.snapshot(), p))? + .on_sync::(|s, p| handlers::handle_on_enter(s.snapshot(), p))? + .on_sync::(|s, p| { + handlers::handle_selection_range(s.snapshot(), p) + })? + .on_sync::(|s, p| { + handlers::handle_find_matching_brace(s.snapshot(), p) + })? .on::(handlers::handle_analyzer_status)? .on::(handlers::handle_syntax_tree)? .on::(handlers::handle_extend_selection)? - .on::(handlers::handle_selection_range)? - .on::(handlers::handle_find_matching_brace)? - .on::(handlers::handle_join_lines)? - .on::(handlers::handle_on_enter)? .on::(handlers::handle_on_type_formatting)? .on::(handlers::handle_document_symbol)? .on::(handlers::handle_workspace_symbol)? @@ -428,6 +432,7 @@ struct PoolDispatcher<'a> { } impl<'a> PoolDispatcher<'a> { + /// Dispatches the request onto the current thread fn on_sync( &mut self, f: fn(&mut ServerWorldState, R::Params) -> Result, @@ -449,6 +454,7 @@ impl<'a> PoolDispatcher<'a> { Ok(self) } + /// Dispatches the request onto thread pool fn on(&mut self, f: fn(ServerWorld, R::Params) -> Result) -> Result<&mut Self> where R: req::Request + 'static, -- cgit v1.2.3