From aaa4861a0b2f6cb2f9f271961d9836976e94b139 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 29 Jan 2020 11:15:08 +0100 Subject: More uniform naming --- crates/ra_lsp_server/src/main_loop.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 52c7e2bdb..2daaf1b4a 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -452,7 +452,7 @@ fn on_request( world: &mut WorldState, pending_requests: &mut PendingRequests, pool: &ThreadPool, - sender: &Sender, + task_sender: &Sender, msg_sender: &Sender, request_received: Instant, req: Request, @@ -461,7 +461,7 @@ fn on_request( req: Some(req), pool, world, - sender, + task_sender, msg_sender, pending_requests, request_received, @@ -661,7 +661,7 @@ struct PoolDispatcher<'a> { world: &'a mut WorldState, pending_requests: &'a mut PendingRequests, msg_sender: &'a Sender, - sender: &'a Sender, + task_sender: &'a Sender, request_received: Instant, } @@ -708,7 +708,7 @@ impl<'a> PoolDispatcher<'a> { self.pool.execute({ let world = self.world.snapshot(); - let sender = self.sender.clone(); + let sender = self.task_sender.clone(); move || { let result = f(world, params); let task = result_to_task::(id, result); @@ -786,7 +786,7 @@ fn update_file_notifications_on_threadpool( pool: &ThreadPool, world: WorldSnapshot, publish_decorations: bool, - sender: Sender, + task_sender: Sender, subscriptions: Vec, ) { log::trace!("updating notifications for {:?}", subscriptions); @@ -802,7 +802,7 @@ fn update_file_notifications_on_threadpool( } Ok(params) => { let not = notification_new::(params); - sender.send(Task::Notify(not)).unwrap(); + task_sender.send(Task::Notify(not)).unwrap(); } } } @@ -815,7 +815,7 @@ fn update_file_notifications_on_threadpool( } Ok(params) => { let not = notification_new::(params); - sender.send(Task::Notify(not)).unwrap(); + task_sender.send(Task::Notify(not)).unwrap(); } } } -- cgit v1.2.3 From 9753eb98ccbe4c5abefacde2fc60e919cf3c5645 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 29 Jan 2020 11:21:49 +0100 Subject: Complain loudly if the main loop is blocked --- crates/ra_lsp_server/src/main_loop.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 2daaf1b4a..9901fe931 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -5,7 +5,14 @@ mod handlers; mod subscriptions; pub(crate) mod pending_requests; -use std::{error::Error, fmt, panic, path::PathBuf, sync::Arc, time::Instant}; +use std::{ + env, + error::Error, + fmt, panic, + path::PathBuf, + sync::Arc, + time::{Duration, Instant}, +}; use crossbeam_channel::{select, unbounded, RecvError, Sender}; use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response}; @@ -425,6 +432,19 @@ fn loop_turn( loop_state.subscriptions.subscriptions(), ) } + + let loop_duration = loop_start.elapsed(); + if loop_duration > Duration::from_millis(10) { + log::error!("overly long loop turn: {:?}", loop_duration); + if env::var("RA_PROFILE").is_ok() { + show_message( + req::MessageType::Error, + format!("overly long loop turn: {:?}", loop_duration), + &connection.sender, + ); + } + } + Ok(()) } -- cgit v1.2.3