Skip to content

Commit

Permalink
Merge pull request #920 from FelixPflaum/bulk-abort-fix
Browse files Browse the repository at this point in the history
Maybe fix bulk sim cancelling itself?
  • Loading branch information
FelixPflaum authored Aug 13, 2024
2 parents a9ca762 + ac5ca03 commit c017c16
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sim/core/bulksim.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,11 @@ func (b *bulkSimRunner) getRankedResults(signals simsignals.Signals, validCombos
var totalCompletedIterations int32
var totalCompletedSims int32

reporterSignal := simsignals.CreateSignals()

// reporter for all sims combined.
go func() {
for !signals.Abort.IsTriggered() {
for !signals.Abort.IsTriggered() && !reporterSignal.Abort.IsTriggered() {
complIters := atomic.LoadInt32(&totalCompletedIterations)
complSims := atomic.LoadInt32(&totalCompletedSims)

Expand Down Expand Up @@ -320,15 +322,15 @@ func (b *bulkSimRunner) getRankedResults(signals simsignals.Signals, validCombos
for i := range rankedResults {
result := <-results
if result.Result == nil || result.Result.Error != nil {
signals.Abort.Trigger() // cancel reporter
reporterSignal.Abort.Trigger() // cancel reporter
return nil, nil, result.Result.Error
}
if !result.Substitution.HasItemReplacements() && result.ChangeLog.TalentLoadout == nil {
baseResult = result
}
rankedResults[i] = result
}
signals.Abort.Trigger() // cancel reporter
reporterSignal.Abort.Trigger() // cancel reporter

sort.Slice(rankedResults, func(i, j int) bool {
return rankedResults[i].Score() > rankedResults[j].Score()
Expand Down

0 comments on commit c017c16

Please sign in to comment.