Skip to content

Commit

Permalink
minor: decoratorEwmaUpdate last
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Aug 15, 2024
1 parent 845e8a4 commit 805f213
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ func (b *Bar) EwmaSetCurrent(current int64, iterDur time.Duration) {
result := make(chan *sync.WaitGroup)
select {
case b.operateState <- func(s *bState) {
var wg sync.WaitGroup
s.decoratorEwmaUpdate(current-s.current, iterDur, &wg)
n := current - s.current
s.current = current
if s.triggerComplete && s.current >= s.total {
s.current = s.total
s.triggerCompletion(b)
}
var wg sync.WaitGroup
s.decoratorEwmaUpdate(n, iterDur, &wg)
result <- &wg
}:
wg := <-result
Expand Down Expand Up @@ -303,13 +304,13 @@ func (b *Bar) EwmaIncrInt64(n int64, iterDur time.Duration) {
result := make(chan *sync.WaitGroup)
select {
case b.operateState <- func(s *bState) {
var wg sync.WaitGroup
s.decoratorEwmaUpdate(n, iterDur, &wg)
s.current += n
if s.triggerComplete && s.current >= s.total {
s.current = s.total
s.triggerCompletion(b)
}
var wg sync.WaitGroup
s.decoratorEwmaUpdate(n, iterDur, &wg)
result <- &wg
}:
wg := <-result
Expand Down

0 comments on commit 805f213

Please sign in to comment.