Start every worker thread through the executors module
Thirty-nine spawn sites in dr-ui, and one in the Android entry point, called std::thread::spawn or a Builder of their own, and most of the threads they started were <unnamed> in a panic message or a profiler. Each now calls executors::spawn with its executor and a role, so the thread is named <executor>:<role> — net:sync, decode:thumbs, io:catalog-open — and knows which executor it is on. The three that already set a name (automation, import, prefetch) keep their name as the role. Behaviour is unchanged: each job still gets a thread of its own when it starts, and spawn panics where std::thread::spawn did. The module's documentation now says how a job is assigned: by what it spends its time on, so a sweep that fetches bytes and then decodes them is Decode, and a sidecar write that touches the catalog is Network. Left as they were: the segmentation and refine workers in masks_ui.rs, which another change is reworking, and test-only threads.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//! The background sweeps: metadata extraction and thumbnail generation
|
||||
//! for whatever the catalog still owes, a chunk at a time.
|
||||
|
||||
use crate::executors::{self, Executor};
|
||||
use dr_catalog::Catalog;
|
||||
use dr_sync::{Connection, RemoteBackend, RemoteId, RemotePath};
|
||||
use dr_thumbs::ThumbStore;
|
||||
@@ -280,7 +281,7 @@ pub fn spawn_sweep(conn: Connection, catalog_path: PathBuf) -> Receiver<SweepMes
|
||||
// The one place this job names a decoder; everything below takes it.
|
||||
let decoder = dr_decode::default();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
executors::spawn(Executor::Decode, "metadata", move || {
|
||||
let catalog = match Catalog::open(&catalog_path) {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
@@ -602,7 +603,7 @@ pub fn spawn_thumbnail_sweep(
|
||||
// The one place this job names a decoder; everything below takes it.
|
||||
let decoder = dr_decode::default();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
executors::spawn(Executor::Decode, "thumb-sweep", move || {
|
||||
let finish_empty = |tx: &Sender<ThumbSweepMessage>| {
|
||||
let _ = tx.send(ThumbSweepMessage::Finished {
|
||||
stored: 0,
|
||||
|
||||
Reference in New Issue
Block a user