Codebase list golang-github-vbauerster-mpb / f0c3727
SetTotal is nop after EnableTriggerComplete Vladimir Bauer 1 year, 11 months ago
1 changed file(s) with 5 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
194194
195195 // SetTotal sets total to an arbitrary value. It's effective only for bar
196196 // which was constructed with `total <= 0`. Setting total to negative value
197 // is equivalent to `(*Bar).SetTotal((*Bar).Current(), bool)` but faster. If
198 // triggerCompletion is true, total value is set to current and complete
199 // event is triggered right away.
200 func (b *Bar) SetTotal(total int64, triggerCompletion bool) {
197 // is equivalent to `(*Bar).SetTotal((*Bar).Current(), bool)` but faster.
198 // If `complete` is true complete event is triggered right away.
199 // Calling `(*Bar).EnableTriggerComplete` makes this one no operational.
200 func (b *Bar) SetTotal(total int64, complete bool) {
201201 select {
202202 case b.operateState <- func(s *bState) {
203203 if s.triggerComplete {
208208 } else {
209209 s.total = total
210210 }
211 if triggerCompletion {
211 if complete {
212212 s.current = s.total
213213 s.completed = true
214214 b.triggerCompletion(s)