RLock() for readonly operation (#11603)

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
int88 2022-11-03 00:22:42 +08:00 committed by GitHub
parent 0fd5253915
commit a0c5669511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {