Codebase list golang-github-vbauerster-mpb / 7030cda
isDone refactoring Vladimir Bauer 9 years ago
1 changed file(s) with 18 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
127127 // Current returns the actual current.
128128 // If bar was stopped by Stop(), subsequent calls to Current will return -1
129129 func (b *Bar) Current() int {
130 if !b.isDone() {
131 respCh := make(chan int)
132 b.currentReqCh <- respCh
133 return <-respCh
134 }
135 return -1
130 if b.isDone() {
131 return -1
132 }
133 respCh := make(chan int)
134 b.currentReqCh <- respCh
135 return <-respCh
136136 }
137137
138138 // Stop stops rendering the bar
162162
163163 // String returns the string representation of the bar
164164 func (b *Bar) String() string {
165 if !b.isDone() {
166 respCh := make(chan []byte)
167 b.redrawReqCh <- respCh
168 return string(<-respCh)
169 }
170 return string(b.lastFrame)
165 if b.isDone() {
166 return string(b.lastFrame)
167 }
168 respCh := make(chan []byte)
169 b.redrawReqCh <- respCh
170 return string(<-respCh)
171171 }
172172
173173 func (b *Bar) server(wg *sync.WaitGroup, total int) {
271271 }
272272
273273 func (b *Bar) status() int {
274 if !b.isDone() {
275 respCh := make(chan int)
276 b.statusReqCh <- respCh
277 return <-respCh
278 }
279 return b.lastStatus
274 if b.isDone() {
275 return b.lastStatus
276 }
277 respCh := make(chan int)
278 b.statusReqCh <- respCh
279 return <-respCh
280280 }
281281
282282 // SortableBarSlice satisfies sort interface