mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
modify the lock
It seems that we did not use the feture of rwlock now. delete the sync.Mutex only use sync.RWMutex.
This commit is contained in:
parent
112e2c6922
commit
c67aee7012
|
@ -8,7 +8,6 @@ import (
|
||||||
// initialize the map entries.
|
// initialize the map entries.
|
||||||
type ConcurrentReadMap struct {
|
type ConcurrentReadMap struct {
|
||||||
rmutex sync.RWMutex
|
rmutex sync.RWMutex
|
||||||
mutex sync.Mutex
|
|
||||||
Items map[string]interface{}
|
Items map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +16,8 @@ func NewConcurrentReadMap() *ConcurrentReadMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ConcurrentReadMap) initMapEntry(key string, newEntry func() interface{}) (value interface{}) {
|
func (m *ConcurrentReadMap) initMapEntry(key string, newEntry func() interface{}) (value interface{}) {
|
||||||
m.mutex.Lock()
|
m.rmutex.Lock()
|
||||||
defer m.mutex.Unlock()
|
defer m.rmutex.Unlock()
|
||||||
if value, ok := m.Items[key]; ok {
|
if value, ok := m.Items[key]; ok {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue