mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-21 23:11:45 +02:00
The lyrics, MusicBrainz, platform resolver and availability services each carried their own copy of the same single-flight machinery: a Flight with an atomic waiter count, a result slot and condvar, a Waiter drop guard, a worker check that fails once the last waiter leaves, a 25 ms wait_timeout poll loop, a MAX_FLIGHTS (64) bound and a finish step that publishes the result, removes the current flight, decrements the active count and wakes shutdown. Move that into crate::coalescer (Flight, Waiter, Coalescer). The table stays inside each service's own state mutex, so cache lookups, joins and finish remain atomic with that service's cache and generation. Per-site rules stay at the call sites: cache keys, what finish caches and when, error values, thread names, worker post-checks, panic messages, MusicBrainz's atomic try_join, its spawn under the state lock and its uncached spawn-failure path. Existing tests only change their access path to the waiter and active counts.