mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Complain loudly if the main loop is blocked
This commit is contained in:
parent
aaa4861a0b
commit
9753eb98cc
@ -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(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user