convert to RWMutex in index, holder, view, and frame

use RLock and RUnlock in mapperLocal hotpath
This commit is contained in:
Matthew Jaffee 2017-09-19 15:52:42 -05:00 • committed by Travis
parent b11b8b074d
commit ce7283ae1b
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
4 changed files with 14 additions and 14 deletions

View file

@ -43,7 +43,7 @@ const (
// Frame represents a container for views.
type Frame struct {
mu sync.Mutex
mu sync.RWMutex
path string
index string
name string
@ -404,8 +404,8 @@ func (f *Frame) Close() error {
// Schema returns the frame's current schema.
func (f *Frame) Schema() *FrameSchema {
f.mu.Lock()
defer f.mu.Unlock()
f.mu.RLock()
defer f.mu.RUnlock()
return f.schema
}
@ -506,8 +506,8 @@ func (f *Frame) ViewPath(name string) string {
// View returns a view in the frame by name.
func (f *Frame) View(name string) *View {
f.mu.Lock()
defer f.mu.Unlock()
f.mu.RLock()
defer f.mu.RUnlock()
return f.view(name)
}

View file

@ -38,7 +38,7 @@ const (
// Holder represents a container for indexes.
type Holder struct {
mu sync.Mutex
mu sync.RWMutex
// Indexes by name.
indexes map[string]*Index
@ -183,8 +183,8 @@ func (h *Holder) IndexPath(name string) string { return filepath.Join(h.Path, na
// Index returns the index by name.
func (h *Holder) Index(name string) *Index {
h.mu.Lock()
defer h.mu.Unlock()
h.mu.RLock()
defer h.mu.RUnlock()
return h.index(name)
}

View file

@ -37,7 +37,7 @@ const (
// Index represents a container for frames.
type Index struct {
mu sync.Mutex
mu sync.RWMutex
path string
name string
@ -345,8 +345,8 @@ func (i *Index) InputDefinitionPath() string {
// Frame returns a frame in the index by name.
func (i *Index) Frame(name string) *Frame {
i.mu.Lock()
defer i.mu.Unlock()
i.mu.RLock()
defer i.mu.RUnlock()
return i.frame(name)
}

View file

@ -43,7 +43,7 @@ func IsValidView(name string) bool {
// View represents a container for frame data.
type View struct {
mu sync.Mutex
mu sync.RWMutex
path string
index string
frame string
@ -194,8 +194,8 @@ func (v *View) FragmentPath(slice uint64) string {
// Fragment returns a fragment in the view by slice.
func (v *View) Fragment(slice uint64) *Fragment {
v.mu.Lock()
defer v.mu.Unlock()
v.mu.RLock()
defer v.mu.RUnlock()
return v.fragment(slice)
}