mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
pkg/wait: change list's lock to RWMutex
Change list's lock from Mutex to RWMutex, which allows concurrent access for list.IsRegistered function.
This commit is contained in:
parent
c9f677c0ea
commit
54fcdb4b5c
@ -34,7 +34,7 @@ type Wait interface {
|
||||
}
|
||||
|
||||
type list struct {
|
||||
l sync.Mutex
|
||||
l sync.RWMutex
|
||||
m map[uint64]chan interface{}
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ func (w *list) Trigger(id uint64, x interface{}) {
|
||||
}
|
||||
|
||||
func (w *list) IsRegistered(id uint64) bool {
|
||||
w.l.Lock()
|
||||
defer w.l.Unlock()
|
||||
w.l.RLock()
|
||||
defer w.l.RUnlock()
|
||||
_, ok := w.m[id]
|
||||
return ok
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user