fix: wrong usage of RLock

This commit is contained in:
wwqgtxx
2024-07-22 09:57:57 +08:00
parent fd5b537ab1
commit 4eb13a73bf
5 changed files with 42 additions and 20 deletions

View File

@@ -59,8 +59,8 @@ func (q *Queue[T]) Copy() []T {
// Len returns the number of items in this queue.
func (q *Queue[T]) Len() int64 {
q.lock.Lock()
defer q.lock.Unlock()
q.lock.RLock()
defer q.lock.RUnlock()
return int64(len(q.items))
}