Explicitly name all spawned threads

The thread name is shown in debugger as well as panic messages and this
patch makes it easier to follow a thread instead of looking through
full backtrace, by naming all spawned threads according to their
functioning.
This commit is contained in:
Manas 2021-07-07 22:18:36 +05:30
parent 2b6770c936
commit 5e6eee5f63
4 changed files with 61 additions and 43 deletions

View file

@ -67,7 +67,10 @@ impl FlycheckHandle {
) -> FlycheckHandle {
let actor = FlycheckActor::new(id, sender, config, workspace_root);
let (sender, receiver) = unbounded::<Restart>();
let thread = jod_thread::spawn(move || actor.run(receiver));
let thread = jod_thread::Builder::new()
.name("FlycheckThread".to_owned())
.spawn(move || actor.run(receiver))
.expect("failed to spawn thread");
FlycheckHandle { sender, thread }
}
@ -266,7 +269,10 @@ impl CargoHandle {
let child_stdout = child.stdout.take().unwrap();
let (sender, receiver) = unbounded();
let actor = CargoActor::new(child_stdout, sender);
let thread = jod_thread::spawn(move || actor.run());
let thread = jod_thread::Builder::new()
.name("CargoHandleThread".to_owned())
.spawn(move || actor.run())
.expect("failed to spawn thread");
CargoHandle { child, thread, receiver }
}
fn join(mut self) -> io::Result<()> {