more read-only locking for maxslice, timequantum, and Index.Frames

This commit is contained in:
Matthew Jaffee 2017-09-19 16:30:37 -05:00 committed by Travis
parent c5b6c39c56
commit 3aecb61285
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
3 changed files with 14 additions and 14 deletions

View file

@ -113,8 +113,8 @@ func (f *Frame) RowAttrStore() *AttrStore { return f.rowAttrStore }
// MaxSlice returns the max slice in the frame.
func (f *Frame) MaxSlice() uint64 {
f.mu.Lock()
defer f.mu.Unlock()
f.mu.RLock()
defer f.mu.RUnlock()
var max uint64
for _, view := range f.views {
@ -129,8 +129,8 @@ func (f *Frame) MaxSlice() uint64 {
// MaxInverseSlice returns the max inverse slice in the frame.
func (f *Frame) MaxInverseSlice() uint64 {
f.mu.Lock()
defer f.mu.Unlock()
f.mu.RLock()
defer f.mu.RUnlock()
view := f.views[ViewInverse]
if view == nil {

View file

@ -276,8 +276,8 @@ func (i *Index) MaxSlice() uint64 {
if i == nil {
return 0
}
i.mu.Lock()
defer i.mu.Unlock()
i.mu.RLock()
defer i.mu.RUnlock()
max := i.remoteMaxSlice
for _, f := range i.frames {
@ -302,8 +302,8 @@ func (i *Index) MaxInverseSlice() uint64 {
if i == nil {
return 0
}
i.mu.Lock()
defer i.mu.Unlock()
i.mu.RLock()
defer i.mu.RUnlock()
max := i.remoteMaxInverseSlice
for _, f := range i.frames {
@ -323,8 +323,8 @@ func (i *Index) SetRemoteMaxInverseSlice(v uint64) {
// TimeQuantum returns the default time quantum for the index.
func (i *Index) TimeQuantum() TimeQuantum {
i.mu.Lock()
defer i.mu.Unlock()
i.mu.RLock()
defer i.mu.RUnlock()
return i.timeQuantum
}
@ -380,8 +380,8 @@ func (i *Index) inputDefinition(name string) *InputDefinition { return i.inputDe
// Frames returns a list of all frames in the index.
func (i *Index) Frames() []*Frame {
i.mu.Lock()
defer i.mu.Unlock()
i.mu.RLock()
defer i.mu.RUnlock()
a := make([]*Frame, 0, len(i.frames))
for _, f := range i.frames {

View file

@ -174,8 +174,8 @@ func (v *View) Close() error {
// MaxSlice returns the max slice in the view.
func (v *View) MaxSlice() uint64 {
v.mu.Lock()
defer v.mu.Unlock()
v.mu.RLock()
defer v.mu.RUnlock()
var max uint64
for slice := range v.fragments {