diff options
Diffstat (limited to 'pkg/priority_queue/pq.go')
-rw-r--r-- | pkg/priority_queue/pq.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pkg/priority_queue/pq.go b/pkg/priority_queue/pq.go index 1b33cb92..2ff52a79 100644 --- a/pkg/priority_queue/pq.go +++ b/pkg/priority_queue/pq.go @@ -1,6 +1,10 @@ package priorityqueue -import "sync" +import ( + "sync" + + priorityqueue "github.com/spiral/roadrunner/v2/common/priority_queue" +) type PQ struct { sync.RWMutex @@ -13,14 +17,14 @@ func NewPriorityQueue() *PQ { } } -func (p *PQ) Insert(item PQItem) { +func (p *PQ) GetMax() priorityqueue.Item { p.Lock() - p.bh.Insert(item) - p.Unlock() + defer p.Unlock() + return p.bh.GetMax() } -func (p *PQ) Get() PQItem { +func (p *PQ) Insert(item priorityqueue.Item) { p.Lock() - defer p.Unlock() - return p.bh.GetMax() + p.bh.Insert(item) + p.Unlock() } |