(
mut worker: WorkerHandle,
queue: Arc<Mutex<VecDeque<String>>>,
results: Arc<Mutex<Vec<ExtractTuple>>>,
skipped: Arc<Mutex<Vec<(String, String)>>>,
progress_count: Arc<AtomicUsize
| 297 | // nothing is moved out inside the function — so we silence it here. |
| 298 | #[allow(clippy::too_many_arguments, clippy::needless_pass_by_value)] |
| 299 | fn worker_thread<F>( |
| 300 | mut worker: WorkerHandle, |
| 301 | queue: Arc<Mutex<VecDeque<String>>>, |
| 302 | results: Arc<Mutex<Vec<ExtractTuple>>>, |
| 303 | skipped: Arc<Mutex<Vec<(String, String)>>>, |
| 304 | progress_count: Arc<AtomicUsize>, |
| 305 | on_progress: Arc<F>, |
| 306 | project_root: PathBuf, |
| 307 | self_path: PathBuf, |
| 308 | token: [u8; TOKEN_LEN], |
| 309 | total: usize, |
| 310 | per_file_timeout: Duration, |
| 311 | ) where |
| 312 | F: Fn(usize, usize, &str) + Send + Sync, |
| 313 | { |
| 314 | loop { |
| 315 | let next = queue |
| 316 | .lock() |
| 317 | .unwrap_or_else(std::sync::PoisonError::into_inner) |
| 318 | .pop_front(); |
| 319 | let Some(file_path) = next else { |
| 320 | break; |
| 321 | }; |
| 322 | |
| 323 | let req = ExtractRequest { |
| 324 | project_root: project_root.clone(), |
| 325 | file_path: file_path.clone(), |
| 326 | }; |
| 327 | |
| 328 | let outcome = round_trip_with_timeout(&mut worker, &req, per_file_timeout); |
| 329 | let n = progress_count.fetch_add(1, Ordering::Relaxed) + 1; |
| 330 | on_progress(n, total, &file_path); |
| 331 | |
| 332 | match outcome { |
| 333 | RoundTripOutcome::Ok(resp) => { |
| 334 | if let Some(data) = resp.data { |
| 335 | results |
| 336 | .lock() |
| 337 | .unwrap_or_else(std::sync::PoisonError::into_inner) |
| 338 | .push(( |
| 339 | resp.file_path, |
| 340 | data.result, |
| 341 | data.content_hash, |
| 342 | data.size, |
| 343 | data.mtime, |
| 344 | )); |
| 345 | } |
| 346 | } |
| 347 | RoundTripOutcome::Timeout => { |
| 348 | eprintln!( |
| 349 | "[tracedecay] extractor timed out on {file_path} after {}s; skipping", |
| 350 | per_file_timeout.as_secs() |
| 351 | ); |
| 352 | skipped |
| 353 | .lock() |
| 354 | .unwrap_or_else(std::sync::PoisonError::into_inner) |
| 355 | .push(( |
| 356 | file_path, |
no test coverage detected