diff --git a/heap_manager.go b/heap_manager.go index cece008..2ee597f 100644 --- a/heap_manager.go +++ b/heap_manager.go @@ -87,9 +87,13 @@ case h_fix: heap.Fix(&bHeap, req.data.(int)) case h_end: + ch := req.data.(chan<- interface{}) + if ch != nil { + go func() { + ch <- []*Bar(bHeap) + }() + } close(m) - data := req.data.(chan []*Bar) - data <- bHeap } } } @@ -117,10 +121,8 @@ m <- heapRequest{cmd: h_push, data: index} } -func (m heapManager) end() []*Bar { - data := make(chan []*Bar) - m <- heapRequest{cmd: h_end, data: data} - return <-data +func (m heapManager) end(ch chan<- interface{}) { + m <- heapRequest{cmd: h_end, data: ch} } func syncWidth(matrix map[int][]chan int) { diff --git a/progress.go b/progress.go index e0e9c39..d29108e 100644 --- a/progress.go +++ b/progress.go @@ -280,13 +280,7 @@ p.cancel() // cancel all bars } case <-p.done: - if s.shutdownNotifier != nil { - go func() { - s.shutdownNotifier <- s.hm.end() - }() - } else { - close(s.hm) - } + s.hm.end(s.shutdownNotifier) close(p.shutdown) return }