Repository navigation
One work pool for the app's background threads - #26
Merged
Merged
Conversation
The biome tiles and the structure markers each had their own copy of the same machinery: a Mutex+Condvar queue of pending keys, a set of keys in progress, workers that take the most urgent key, keep per-seed state, send the result before leaving the in-progress set, and call egui's request_repaint. The spawn and the strongholds each had their own copy of a one-shot background computation. None of it could be tested without egui. crates/chunkscope-app/src/work.rs now holds it once: - WorkPool<K, V>: new(name, workers, wake, compute(&mut state, key)), request(wanted, done) -> keys still to come, receive(). - Job<T>: spawn(name, wake, compute), is_loading(), get(). The wake is a plain function (the app passes request_repaint). Dropping a pool now also stops its idle workers. TileCache and StructureCache keep their caches and become thin users of the pool; Spawn and Strongholds wrap a Job. Seven new unit tests cover the queueing rules (most urgent first, the key in progress is not queued again, a new request drops stale work, done keys are skipped, per-worker state, the wake, idle workers stopping on drop, a job delivering once); each rule was broken on purpose and a test failed. The app shows the same map and markers as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SenGxDDRwLejx8nir8GXKG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal #5 from the architecture review: one work pool for the app's background threads.
Before
TileCacheandStructureCacheeach had their own copy of the same machinery:request_repaint.SpawnandStrongholdseach had their own copy of a one-shot background computation.egui::Context, so none of it could be tested.After
New
crates/chunkscope-app/src/work.rs:WorkPool<K, V>:new(name, workers, wake, compute(&mut state, key));request(wanted, done), which returns the number of keys still to come;receive().Job<T>:spawn(name, wake, compute),is_loading(),get().request_repaint.TileCacheandStructureCachekeep their caches and become thin users of the pool.SpawnandStrongholdswrap aJob. Net change in the existing files: 99 lines added, 261 removed, not counting the new module.Tests
No behaviour change, so no release.
Generated by Claude Code