isDone refactoring
Vladimir Bauer
9 years ago
| 127 | 127 | // Current returns the actual current. |
| 128 | 128 | // If bar was stopped by Stop(), subsequent calls to Current will return -1 |
| 129 | 129 | 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 | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Stop stops rendering the bar |
| 162 | 162 | |
| 163 | 163 | // String returns the string representation of the bar |
| 164 | 164 | 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) | |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | func (b *Bar) server(wg *sync.WaitGroup, total int) { |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | 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 | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // SortableBarSlice satisfies sort interface |