Skip to content

Commit

Permalink
use read lock when getting data
Browse files Browse the repository at this point in the history
  • Loading branch information
cooldarkdryplace committed May 5, 2018
1 parent 2d2ed79 commit 010f94a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type Storage struct {
sync.Mutex
sync.RWMutex
buckets map[string][]Request
records *list
}
Expand All @@ -27,8 +27,8 @@ func NewStorage() *Storage {
}

func (s *Storage) Get(id string) []Request {
s.Lock()
defer s.Unlock()
s.RLock()
defer s.RUnlock()
return s.buckets[id]
}

Expand Down

0 comments on commit 010f94a

Please sign in to comment.