diff --git a/heap_manager.go b/heap_manager.go index fe2152d..5233a10 100644 --- a/heap_manager.go +++ b/heap_manager.go @@ -14,6 +14,7 @@ h_iter h_pop_all h_fix + h_end ) type heapRequest struct { @@ -82,6 +83,10 @@ close(data.iter) case h_fix: heap.Fix(&bHeap, req.data.(int)) + case h_end: + close(m) + data := req.data.(chan []*Bar) + data <- bHeap } } } @@ -108,3 +113,9 @@ func (m heapManager) fix(index int) { 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 +}