general: Name spawned threads

This is for easier debugging in case a panic happens -
instead of dealing with "thread <unnamed> paniced...", etc.,
we get a name relevant to our context.
This commit is contained in:
Christopher Davis 2022-08-03 19:53:32 -04:00
parent d99215bfd1
commit 37f170b165
2 changed files with 12 additions and 8 deletions

View file

@ -152,10 +152,12 @@ impl LpImagePage {
async fn load_texture_from_file(file: &gio::File) -> Result<gdk::Texture, glib::Error> {
let (sender, receiver) = futures_channel::oneshot::channel();
std::thread::spawn(clone!(@weak file => move || {
let result = gdk::Texture::from_file(&file);
sender.send(result).unwrap()
}));
let _ = std::thread::Builder::new()
.name("Load Texture".to_string())
.spawn(clone!(@weak file => move || {
let result = gdk::Texture::from_file(&file);
sender.send(result).unwrap()
}));
receiver.await.unwrap()
}