diff --git a/bar.go b/bar.go index ac815aa..8fa5d6f 100644 --- a/bar.go +++ b/bar.go @@ -376,6 +376,20 @@ } } +// IsRunning reports whether the bar is running, i.e. not yet completed +// and not yet aborted. +func (b *Bar) IsRunning() bool { + result := make(chan bool) + select { + case b.operateState <- func(s *bState) { + result <- !s.completed && !s.aborted + }: + return <-result + case <-b.done: + return false + } +} + // Wait blocks until bar is completed or aborted. func (b *Bar) Wait() { <-b.done @@ -456,20 +470,6 @@ } } -// IsRunning reports whether the bar is running, i.e. not yet completed -// and not yet aborted. -func (b *Bar) IsRunning() bool { - result := make(chan bool) - select { - case b.operateState <- func(s *bState) { - result <- !s.completed && !s.aborted - }: - return <-result - case <-b.done: - return false - } -} - func (b *Bar) wSyncTable() [][]chan int { result := make(chan [][]chan int) select {