Skip to content

Commit 5fdee9a

Browse files
TMHSDigitalclaude
andcommitted
Split scan.Run into preflight, ticker and worker helpers (#277)
Run had grown back to 248 lines as preflight, wildcard, retry, pool and deadline work landed inside it. It is now 109 lines: - preflight() runs the scope, recursion-ceiling, resolver and wildcard checks and reports whether the scan may go on, as a pure move. - scanState.startTicker and scanState.runWorkers hold the progress ticker and the worker pool. - processed, found and total are atomic.Int64 fields on scanState instead of raw *int64 with atomic.LoadInt64; the dispatcher takes *atomic.Int64 for the total. The exactly-one-EventDone contract (#99) is unchanged: early exits still return through Run's deferred Stopped done, which TestRunAlwaysEndsWithOneDone covers for every exit. Fixes #277 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 160208c commit 5fdee9a

2 files changed

Lines changed: 125 additions & 114 deletions

File tree

‎internal/scan/dispatcher.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (d *dispatcher) finish(ctx context.Context, stats *counters, events chan<-
299299
// completed), and run expands them. total receives the progress total as it
300300
// changes.
301301
func (d *dispatcher) run(ctx context.Context, workers int, jobs chan<- []job, enqueue <-chan job, completed <-chan []completion,
302-
total *int64, stats *counters, events chan<- Event) {
302+
total *atomic.Int64, stats *counters, events chan<- Event) {
303303
defer close(jobs)
304304
// The deadline timer wakes the dispatcher while it waits on a busy
305305
// worker pool, so the budget holds even if no job completes (#190).
@@ -309,7 +309,7 @@ func (d *dispatcher) run(ctx context.Context, workers int, jobs chan<- []job, en
309309
defer timer.Stop()
310310
deadline = timer.C
311311
}
312-
publish := func() { atomic.StoreInt64(total, d.total()) }
312+
publish := func() { total.Store(d.total()) }
313313

314314
var ready []job
315315
for {

0 commit comments

Comments
 (0)