convert some locks to rlocks

This commit is contained in:
Matthew Jaffee 2018-01-09 13:50:40 -06:00
parent 42032584b5
commit 55de0402d2
No known key found for this signature in database
GPG key ID: 51C676AF9FFCDB87
2 changed files with 5 additions and 6 deletions

View file

@ -533,8 +533,8 @@ func (f *Frame) view(name string) *View { return f.views[name] }
// Views returns a list of all views in the frame.
func (f *Frame) Views() []*View {
f.mu.Lock()
defer f.mu.Unlock()
f.mu.RLock()
defer f.mu.RUnlock()
other := make([]*View, 0, len(f.views))
for _, view := range f.views {

View file

@ -196,15 +196,14 @@ func (h *Holder) index(name string) *Index { return h.indexes[name] }
// Indexes returns a list of all indexes in the holder.
func (h *Holder) Indexes() []*Index {
h.mu.Lock()
defer h.mu.Unlock()
h.mu.RLock()
a := make([]*Index, 0, len(h.indexes))
for _, index := range h.indexes {
a = append(a, index)
}
sort.Sort(indexSlice(a))
h.mu.RUnlock()
sort.Sort(indexSlice(a))
return a
}