github.com/aavshr/aws-sdk-go@v1.41.3/aws/crr/sync_map_1_8.go (about) 1 //go:build !go1.9 2 // +build !go1.9 3 4 package crr 5 6 import ( 7 "sync" 8 ) 9 10 type syncMap struct { 11 container map[interface{}]interface{} 12 lock sync.RWMutex 13 } 14 15 func newSyncMap() syncMap { 16 return syncMap{ 17 container: map[interface{}]interface{}{}, 18 } 19 } 20 21 func (m *syncMap) Load(key interface{}) (interface{}, bool) { 22 m.lock.RLock() 23 defer m.lock.RUnlock() 24 25 v, ok := m.container[key] 26 return v, ok 27 } 28 29 func (m *syncMap) Store(key interface{}, value interface{}) { 30 m.lock.Lock() 31 defer m.lock.Unlock() 32 33 m.container[key] = value 34 } 35 36 func (m *syncMap) Delete(key interface{}) { 37 m.lock.Lock() 38 defer m.lock.Unlock() 39 40 delete(m.container, key) 41 } 42 43 func (m *syncMap) Range(f func(interface{}, interface{}) bool) { 44 for k, v := range m.container { 45 if !f(k, v) { 46 return 47 } 48 } 49 }