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

@ -31,7 +31,10 @@ impl loader::Handle for NotifyHandle {
fn spawn(sender: loader::Sender) -> NotifyHandle {
let actor = NotifyActor::new(sender);
let (sender, receiver) = unbounded::<Message>();
let thread = jod_thread::spawn(move || actor.run(receiver));
let thread = jod_thread::Builder::new()
.name("LoaderThread".to_owned())
.spawn(move || actor.run(receiver))
.expect("failed to spawn thread");
NotifyHandle { sender, thread }
}
fn set_config(&mut self, config: loader::Config) {