Codebase list golang-github-vbauerster-mpb / 4772f20
avoid potential race in test Vladimir Bauer 7 years ago
1 changed file(s) with 5 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
44 "fmt"
55 "io/ioutil"
66 "strings"
7 "sync/atomic"
78 "testing"
89 "time"
910 "unicode/utf8"
147148
148149 total := 100
149150 panicMsg := "Upps!!!"
150 var pCount int
151 var pCount uint32
151152 bar := p.AddBar(int64(total),
152153 PrependDecorators(panicDecorator(panicMsg,
153154 func(st *decor.Statistics) bool {
154155 if st.Current >= 42 {
155 pCount++
156 atomic.AddUint32(&pCount, 1)
156157 return true
157158 }
158159 return false
183184
184185 total := 100
185186 panicMsg := "Upps!!!"
186 var pCount int
187 var pCount uint32
187188 bar := p.AddBar(int64(total),
188189 PrependDecorators(panicDecorator(panicMsg,
189190 func(st *decor.Statistics) bool {
190191 if st.Completed {
191 pCount++
192 atomic.AddUint32(&pCount, 1)
192193 return true
193194 }
194195 return false