mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
refactor(lib): extract analysis runtime queues into own module
Move ~440 LOC of analysis-queue plumbing out of lib.rs into a new src-tauri/src/analysis_runtime.rs: - AnalysisBackfillQueueState/Shared + worker loop + lazy-init - AnalysisCpuSeedQueueState/Shared + worker loop + lazy-init - submit_analysis_cpu_seed - emit_analysis_queue_snapshot_line + analysis_queue_snapshot_loop - WaveformUpdatedPayload (only used internally) External callers keep their existing paths via `pub(crate) use analysis_runtime::*` re-export at the lib.rs root. Direct accesses to the static globals from app_api/analysis.rs are replaced with a new prune_analysis_queues(keep) function so the statics stay private. lib.rs goes from 999 → ~540 LOC. sync_cancel_flags stays put (sync domain, separate concern). Tray-related types stay too — they're a separate split candidate. Behaviour-preserving: same workers, same queues, same events, same return shapes. cargo check clean.
This commit is contained in:
@@ -205,25 +205,8 @@ pub(crate) fn analysis_prune_pending_to_track_ids(
|
||||
}
|
||||
let keep_track_ids: HashSet<&str> = normalized.iter().map(|s| s.as_str()).collect();
|
||||
|
||||
let http_removed = if let Some(shared) = ANALYSIS_BACKFILL.get() {
|
||||
let mut st = shared
|
||||
.state
|
||||
.lock()
|
||||
.map_err(|_| "analysis backfill lock poisoned".to_string())?;
|
||||
st.prune_queued_not_in(&keep_track_ids)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
let (cpu_removed_jobs, cpu_removed_waiters) = if let Some(shared) = ANALYSIS_CPU_SEED.get() {
|
||||
let mut st = shared
|
||||
.state
|
||||
.lock()
|
||||
.map_err(|_| "analysis cpu-seed lock poisoned".to_string())?;
|
||||
st.prune_queued_not_in(&keep_track_ids)
|
||||
} else {
|
||||
(0, 0)
|
||||
};
|
||||
let (http_removed, cpu_removed_jobs, cpu_removed_waiters) =
|
||||
prune_analysis_queues(&keep_track_ids)?;
|
||||
|
||||
if http_removed > 0 || cpu_removed_jobs > 0 {
|
||||
crate::app_deprintln!(
|
||||
|
||||
Reference in New Issue
Block a user