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

@ -37,9 +37,12 @@ impl ProcMacroProcessSrv {
let process = Process::run(process_path, args)?;
let (task_tx, task_rx) = bounded(0);
let handle = jod_thread::spawn(move || {
client_loop(task_rx, process);
});
let handle = jod_thread::Builder::new()
.name("ProcMacroClientThread".to_owned())
.spawn(move || {
client_loop(task_rx, process);
})
.expect("failed to spawn thread");
let task_tx = Arc::new(task_tx);
let srv = ProcMacroProcessSrv { inner: Arc::downgrade(&task_tx) };