Skip to content

Commit 43b7aef

Browse files
committed
Fix stopping before all workers had finished
1 parent 7729489 commit 43b7aef

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

find_arctan_formulae.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ func groupToMapKey(s []uint32) string {
473473

474474
// Find the possible Norms for the prime group and call PSLQ on them
475475
func processPrimeGroupsWorker(primeMap map[uint32][]*Norm, ch chan []uint32, wg *sync.WaitGroup) {
476+
defer wg.Done()
476477
baseValid := make([]*Norm, 0, 100)
477478
for group := range ch {
478479
valid := baseValid[:0]
@@ -570,6 +571,7 @@ func processPrimeGroups(norms []*Norm, primeMap map[uint32][]*Norm, primesToProc
570571
ch := make(chan []uint32, workers)
571572

572573
for range workers {
574+
wg.Add(1)
573575
go processPrimeGroupsWorker(primeMap, ch, &wg)
574576
}
575577

@@ -610,6 +612,7 @@ func processPrimeGroups(norms []*Norm, primeMap map[uint32][]*Norm, primesToProc
610612
}
611613

612614
close(ch)
615+
Printf("Waiting for workers to finish\n")
613616
wg.Wait()
614617

615618
statsMu.Lock()

0 commit comments

Comments
 (0)