From a0c56695113cdf1a4b84ae1a666496cfbd6f219b Mon Sep 17 00:00:00 2001 From: int88 <106391185+int88@users.noreply.github.com> Date: Thu, 3 Nov 2022 00:22:42 +0800 Subject: [PATCH] RLock() for readonly operation (#11603) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Radosław Kapka --- container/queue/priority_queue.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/container/queue/priority_queue.go b/container/queue/priority_queue.go index e4629026a..9a240c43b 100644 --- a/container/queue/priority_queue.go +++ b/container/queue/priority_queue.go @@ -152,8 +152,8 @@ func (pq *PriorityQueue) PopByKey(key string) (*Item, error) { // RetrieveByKey searches the queue for an item with the given key and returns it // from the queue if found. Returns nil if not found. func (pq *PriorityQueue) RetrieveByKey(key string) *Item { - pq.lock.Lock() - defer pq.lock.Unlock() + pq.lock.RLock() + defer pq.lock.RUnlock() item, ok := pq.dataMap[key] if !ok {