minor: param rename
Vladimir Bauer
3 years ago
| 198 | 198 | // SetTotal sets total to an arbitrary value. It's effective only for |
| 199 | 199 | // bar which was constructed with `total <= 0`. Setting total to negative |
| 200 | 200 | // value is equivalent to (*Bar).SetTotal((*Bar).Current(), bool) but faster. |
| 201 | // If triggerCompleteNow is true, total value is set to current and | |
| 201 | // If triggerCompletion is true, total value is set to current and | |
| 202 | 202 | // complete event is triggered right away. |
| 203 | func (b *Bar) SetTotal(total int64, triggerCompleteNow bool) { | |
| 203 | func (b *Bar) SetTotal(total int64, triggerCompletion bool) { | |
| 204 | 204 | select { |
| 205 | 205 | case b.operateState <- func(s *bState) { |
| 206 | 206 | if s.triggerComplete { |
| 211 | 211 | } else { |
| 212 | 212 | s.total = total |
| 213 | 213 | } |
| 214 | if triggerCompleteNow { | |
| 214 | if triggerCompletion { | |
| 215 | 215 | s.current = s.total |
| 216 | 216 | s.completed = true |
| 217 | 217 | b.triggerCompletion(s) |