From 54fcdb4b5ceea6fe0e858071efc3f46806407cfc Mon Sep 17 00:00:00 2001 From: lorneli Date: Sun, 27 Aug 2017 18:03:31 +0800 Subject: [PATCH] pkg/wait: change list's lock to RWMutex Change list's lock from Mutex to RWMutex, which allows concurrent access for list.IsRegistered function. --- pkg/wait/wait.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/wait/wait.go b/pkg/wait/wait.go index 34fa237e8..9b1df419e 100644 --- a/pkg/wait/wait.go +++ b/pkg/wait/wait.go @@ -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 }