Add remove bool param to *Progress.Abort method
Vladimir Bauer
7 years ago
| 117 | 117 | // it means remove bar now without waiting for its completion. |
| 118 | 118 | // If bar is already completed, there is nothing to abort. |
| 119 | 119 | // If you need to remove bar after completion, use BarRemoveOnComplete BarOption. |
| 120 | func (p *Progress) Abort(b *Bar) { | |
| 120 | func (p *Progress) Abort(b *Bar, remove bool) { | |
| 121 | 121 | select { |
| 122 | 122 | case p.operateState <- func(s *pState) { |
| 123 | 123 | if b.index < 0 { |
| 124 | 124 | return |
| 125 | 125 | } |
| 126 | s.heapUpdated = heap.Remove(s.bHeap, b.index) != nil | |
| 126 | if remove { | |
| 127 | s.heapUpdated = heap.Remove(s.bHeap, b.index) != nil | |
| 128 | } | |
| 127 | 129 | s.shutdownPending = append(s.shutdownPending, b) |
| 128 | 130 | }: |
| 129 | 131 | case <-p.done: |