Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
use read-lock in empty and count
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranrg committed Jul 18, 2017
1 parent 644ed44 commit b16da68
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/set/syncset.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ func (t *syncset) Clear() {
// Empty checks if the set is empty
func (t *syncset) Empty() bool {

t.Lock()
defer t.Unlock()
t.RLock()
defer t.RUnlock()

return t.set.Empty()
}

// Count returns the size of the set
func (t *syncset) Count() int {

t.Lock()
defer t.Unlock()
t.RLock()
defer t.RUnlock()

return t.set.Count()
}
Expand Down

0 comments on commit b16da68

Please sign in to comment.