Browse Source

modify the lock

It seems that we did not use the feture of rwlock now.
delete the sync.Mutex only use sync.RWMutex.
pull/287/head
bluefoxah 9 years ago
parent
commit
c67aee7012
  1. 5
      go/util/concurrent_read_map.go

5
go/util/concurrent_read_map.go

@ -8,7 +8,6 @@ import (
// initialize the map entries.
type ConcurrentReadMap struct {
rmutex sync.RWMutex
mutex sync.Mutex
Items map[string]interface{}
}
@ -17,8 +16,8 @@ func NewConcurrentReadMap() *ConcurrentReadMap {
}
func (m *ConcurrentReadMap) initMapEntry(key string, newEntry func() interface{}) (value interface{}) {
m.mutex.Lock()
defer m.mutex.Unlock()
m.rmutex.Lock()
defer m.rmutex.Unlock()
if value, ok := m.Items[key]; ok {
return value
}

Loading…
Cancel
Save