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

@@ -17,8 +17,8 @@ func NewCallback[T any]() *Callback[T] {
}
func (c *Callback[T]) Register(item func(T)) io.Closer {
c.mutex.RLock()
defer c.mutex.RUnlock()
c.mutex.Lock()
defer c.mutex.Unlock()
element := c.list.PushBack(item)
return &callbackCloser[T]{
element: element,