Give all threads names
This commit is contained in:
parent
9efa23c4da
commit
83a1ad5bfe
@ -494,7 +494,7 @@ fn spawn(mut command: Command) -> std::io::Result<CommandHandle> {
|
|||||||
let (sender, receiver) = unbounded();
|
let (sender, receiver) = unbounded();
|
||||||
let actor = CargoActor::new(sender, stdout, stderr);
|
let actor = CargoActor::new(sender, stdout, stderr);
|
||||||
let thread = stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker)
|
let thread = stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker)
|
||||||
.name("CargoHandle".to_owned())
|
.name("CommandHandle".to_owned())
|
||||||
.spawn(move || actor.run())
|
.spawn(move || actor.run())
|
||||||
.expect("failed to spawn thread");
|
.expect("failed to spawn thread");
|
||||||
Ok(CommandHandle { program, arguments, current_dir, child, thread, receiver })
|
Ok(CommandHandle { program, arguments, current_dir, child, thread, receiver })
|
||||||
|
@ -82,6 +82,7 @@ enum ParallelPrimeCacheWorkerProgress {
|
|||||||
|
|
||||||
stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker)
|
stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker)
|
||||||
.allow_leak(true)
|
.allow_leak(true)
|
||||||
|
.name("PrimeCaches".to_owned())
|
||||||
.spawn(move || Cancelled::catch(|| worker(db)))
|
.spawn(move || Cancelled::catch(|| worker(db)))
|
||||||
.expect("failed to spawn thread");
|
.expect("failed to spawn thread");
|
||||||
}
|
}
|
||||||
|
@ -90,18 +90,13 @@ pub(crate) fn handle_did_change_text_document(
|
|||||||
let _p = tracing::span!(tracing::Level::INFO, "handle_did_change_text_document").entered();
|
let _p = tracing::span!(tracing::Level::INFO, "handle_did_change_text_document").entered();
|
||||||
|
|
||||||
if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) {
|
if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) {
|
||||||
let data = match state.mem_docs.get_mut(&path) {
|
let Some(DocumentData { version, data }) = state.mem_docs.get_mut(&path) else {
|
||||||
Some(doc) => {
|
tracing::error!("unexpected DidChangeTextDocument: {}", path);
|
||||||
// The version passed in DidChangeTextDocument is the version after all edits are applied
|
return Ok(());
|
||||||
// so we should apply it before the vfs is notified.
|
|
||||||
doc.version = params.text_document.version;
|
|
||||||
&mut doc.data
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
tracing::error!("unexpected DidChangeTextDocument: {}", path);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
// The version passed in DidChangeTextDocument is the version after all edits are applied
|
||||||
|
// so we should apply it before the vfs is notified.
|
||||||
|
*version = params.text_document.version;
|
||||||
|
|
||||||
let new_contents = apply_document_changes(
|
let new_contents = apply_document_changes(
|
||||||
state.config.position_encoding(),
|
state.config.position_encoding(),
|
||||||
|
@ -12,27 +12,33 @@
|
|||||||
/// Creates an LSP connection via stdio.
|
/// Creates an LSP connection via stdio.
|
||||||
pub(crate) fn stdio_transport() -> (Sender<Message>, Receiver<Message>, IoThreads) {
|
pub(crate) fn stdio_transport() -> (Sender<Message>, Receiver<Message>, IoThreads) {
|
||||||
let (writer_sender, writer_receiver) = bounded::<Message>(0);
|
let (writer_sender, writer_receiver) = bounded::<Message>(0);
|
||||||
let writer = thread::spawn(move || {
|
let writer = thread::Builder::new()
|
||||||
let stdout = stdout();
|
.name("LspServerWriter".to_owned())
|
||||||
let mut stdout = stdout.lock();
|
.spawn(move || {
|
||||||
writer_receiver.into_iter().try_for_each(|it| it.write(&mut stdout))
|
let stdout = stdout();
|
||||||
});
|
let mut stdout = stdout.lock();
|
||||||
|
writer_receiver.into_iter().try_for_each(|it| it.write(&mut stdout))
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
let (reader_sender, reader_receiver) = bounded::<Message>(0);
|
let (reader_sender, reader_receiver) = bounded::<Message>(0);
|
||||||
let reader = thread::spawn(move || {
|
let reader = thread::Builder::new()
|
||||||
let stdin = stdin();
|
.name("LspServerReader".to_owned())
|
||||||
let mut stdin = stdin.lock();
|
.spawn(move || {
|
||||||
while let Some(msg) = Message::read(&mut stdin)? {
|
let stdin = stdin();
|
||||||
let is_exit = matches!(&msg, Message::Notification(n) if n.is_exit());
|
let mut stdin = stdin.lock();
|
||||||
|
while let Some(msg) = Message::read(&mut stdin)? {
|
||||||
|
let is_exit = matches!(&msg, Message::Notification(n) if n.is_exit());
|
||||||
|
|
||||||
debug!("sending message {:#?}", msg);
|
debug!("sending message {:#?}", msg);
|
||||||
reader_sender.send(msg).expect("receiver was dropped, failed to send a message");
|
reader_sender.send(msg).expect("receiver was dropped, failed to send a message");
|
||||||
|
|
||||||
if is_exit {
|
if is_exit {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
Ok(())
|
||||||
Ok(())
|
})
|
||||||
});
|
.unwrap();
|
||||||
let threads = IoThreads { reader, writer };
|
let threads = IoThreads { reader, writer };
|
||||||
(writer_sender, reader_receiver, threads)
|
(writer_sender, reader_receiver, threads)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user