Skip to content

Commit

Permalink
Name mutexes consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
wishdev committed May 14, 2020
1 parent 9ec09ea commit becf132
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions har/entrylist.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

// EntryList implements the har.EntryContainer interface for the storage of har.Entry
type EntryList struct {
lock sync.Mutex
mu sync.Mutex
items *list.List
}

Expand All @@ -33,16 +33,16 @@ func NewEntryList() *EntryList {

// AddEntry adds an entry to the entry list
func (el *EntryList) AddEntry(entry *Entry) {
el.lock.Lock()
defer el.lock.Unlock()
el.mu.Lock()
defer el.mu.Unlock()

el.items.PushBack(entry)
}

// Entries returns a slice containing all entries
func (el *EntryList) Entries() []*Entry {
el.lock.Lock()
defer el.lock.Unlock()
el.mu.Lock()
defer el.mu.Unlock()

es := make([]*Entry, 0, el.items.Len())

Expand All @@ -55,8 +55,8 @@ func (el *EntryList) Entries() []*Entry {

// RemoveMatches takes a matcher function and returns all entries that return true from the function
func (el *EntryList) RemoveCompleted() []*Entry {
el.lock.Lock()
defer el.lock.Unlock()
el.mu.Lock()
defer el.mu.Unlock()

es := make([]*Entry, 0, el.items.Len())
var next *list.Element
Expand All @@ -76,8 +76,8 @@ func (el *EntryList) RemoveCompleted() []*Entry {

// RemoveEntry removes and entry from the entry list via the entry's id
func (el *EntryList) RemoveEntry(id string) *Entry {
el.lock.Lock()
defer el.lock.Unlock()
el.mu.Lock()
defer el.mu.Unlock()

if e, en := el.retrieveElementEntry(id); e != nil {
el.items.Remove(e)
Expand All @@ -90,16 +90,16 @@ func (el *EntryList) RemoveEntry(id string) *Entry {

// Reset reinitializes the entrylist
func (el *EntryList) Reset() {
el.lock.Lock()
defer el.lock.Unlock()
el.mu.Lock()
defer el.mu.Unlock()

el.items.Init()
}

// RetrieveEntry returns an entry from the entrylist via the entry's id
func (el *EntryList) RetrieveEntry(id string) *Entry {
el.lock.Lock()
defer el.lock.Unlock()
el.mu.Lock()
defer el.mu.Unlock()

_, en := el.retrieveElementEntry(id)

Expand Down

0 comments on commit becf132

Please sign in to comment.