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:
@@ -32,6 +32,7 @@
|
||||
//! share boundary the account cannot write to. The scanner excludes it by the
|
||||
//! same mechanism that excludes the trash.
|
||||
|
||||
use crate::executors::{self, Executor};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use dr_sync::{Connection, RemoteBackend, RemoteError, RemoteId, RemotePath};
|
||||
@@ -132,7 +133,7 @@ pub fn spawn_sync(
|
||||
) -> std::sync::mpsc::Receiver<SyncMessage> {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
executors::spawn(Executor::Network, "sync", move || {
|
||||
// A current-thread runtime here is what made the library scan itself
|
||||
// rather than adopt the shards the server already had; see net_runtime.
|
||||
let rt = match crate::net_runtime::build() {
|
||||
@@ -1018,7 +1019,7 @@ pub fn spawn_place_fetch(
|
||||
) -> std::sync::mpsc::Receiver<Result<Option<dr_types::Place>, String>> {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
executors::spawn(Executor::Network, "places", move || {
|
||||
let rt = match crate::net_runtime::build() {
|
||||
Ok(rt) => rt,
|
||||
Err(e) => {
|
||||
|
||||
Reference in New Issue
Block a user