Skip to content

Commit

Permalink
move all the state globals up top
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed May 5, 2024
1 parent a842d1d commit 1b813ea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ var queueCond = sync.Cond{L: &queueLock}
var queue []string // FIXME: should be a resizable ring buffer
var currentlyWorkingWorkers uint

var lazyHasherBackoff chan struct{}

var totalDedupped atomic.Uint64
var totalDeddupingErrors atomic.Uint64

// decrementCurrentlyWorkingWorkers must be called while holding [queueLock].
func decrementCurrentlyWorkingWorkers() {
currentlyWorkingWorkers--
Expand Down Expand Up @@ -235,8 +240,6 @@ func scan(f *os.File, p string, length, blocksize uint64) error {
return hashFile(f, length, p, false)
}

var lazyHasherBackoff chan struct{}

func doLazyHash(other string, length uint64) {
defer wg.Done()
defer func() { <-lazyHasherBackoff }()
Expand Down Expand Up @@ -285,9 +288,6 @@ func hashFile(f *os.File, length uint64, p string, statsWereAlreadyRecorded bool
return nil
}

var totalDedupped atomic.Uint64
var totalDeddupingErrors atomic.Uint64

func dedup(backoff chan struct{}, length uint64, paths ...string) {
defer func() { <-backoff }()

Expand Down

0 comments on commit 1b813ea

Please sign in to comment.