diff options
author | Valery Piashchynski <[email protected]> | 2021-07-07 21:37:37 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-07-07 21:37:37 +0300 |
commit | b84a7cb26c184b709f18d3d52925b31d49351c03 (patch) | |
tree | 5be8fafccbb2e7ad2dc6496e8a5f1d212a65a8bb /pkg/priorityqueue/binary_heap.go | |
parent | 60c229c8506df465586434309af5acd1f84e2406 (diff) |
New Methods in the binary heap interface...
Add Len() method to the Binary Heaps interface with implementation.
Start consumers only for the user-defined set from the config.
Add Headers field to the proto
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/priorityqueue/binary_heap.go')
-rw-r--r-- | pkg/priorityqueue/binary_heap.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/priorityqueue/binary_heap.go b/pkg/priorityqueue/binary_heap.go index 47fdf5e5..a8d80fc0 100644 --- a/pkg/priorityqueue/binary_heap.go +++ b/pkg/priorityqueue/binary_heap.go @@ -68,6 +68,10 @@ func (bh *BinHeap) fixDown(curr, end int) { } } +func (bh *BinHeap) Len() uint64 { + return atomic.LoadUint64(&bh.len) +} + func (bh *BinHeap) Insert(item Item) { bh.cond.L.Lock() bh.items = append(bh.items, item) @@ -87,7 +91,7 @@ func (bh *BinHeap) GetMax() Item { bh.cond.L.Lock() defer bh.cond.L.Unlock() - if atomic.LoadUint64(&bh.len) == 0 { + for atomic.LoadUint64(&bh.len) == 0 { bh.cond.Wait() } |