minor: move pub method to top
Vladimir Bauer
3 years ago
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | // IsRunning reports whether the bar is running, i.e. not yet completed | |
| 379 | // and not yet aborted. | |
| 380 | func (b *Bar) IsRunning() bool { | |
| 381 | result := make(chan bool) | |
| 382 | select { | |
| 383 | case b.operateState <- func(s *bState) { | |
| 384 | result <- !s.completed && !s.aborted | |
| 385 | }: | |
| 386 | return <-result | |
| 387 | case <-b.done: | |
| 388 | return false | |
| 389 | } | |
| 390 | } | |
| 391 | ||
| 378 | 392 | // Wait blocks until bar is completed or aborted. |
| 379 | 393 | func (b *Bar) Wait() { |
| 380 | 394 | <-b.done |
| 455 | 469 | } |
| 456 | 470 | } |
| 457 | 471 | |
| 458 | // IsRunning reports whether the bar is running, i.e. not yet completed | |
| 459 | // and not yet aborted. | |
| 460 | func (b *Bar) IsRunning() bool { | |
| 461 | result := make(chan bool) | |
| 462 | select { | |
| 463 | case b.operateState <- func(s *bState) { | |
| 464 | result <- !s.completed && !s.aborted | |
| 465 | }: | |
| 466 | return <-result | |
| 467 | case <-b.done: | |
| 468 | return false | |
| 469 | } | |
| 470 | } | |
| 471 | ||
| 472 | 472 | func (b *Bar) wSyncTable() [][]chan int { |
| 473 | 473 | result := make(chan [][]chan int) |
| 474 | 474 | select { |