15
}
16
18
>
return SyncMap[K, V]{
19
>
RWMutex: &sync.RWMutex{},
20
>
contents: make(map[K]V),
21
>
}
22
>
}
23
25
>
m.RLock()
26
>
defer m.RUnlock()
27
>
value, ok = m.contents[key]
28
>
return
29
>
}
30
32
>
m.RLock()
33
>
currentValue, ok := m.contents[key]
34
>
m.RUnlock()
35
>
if ok {
37
>
}
38
40
>
defer m.Unlock()
41
>
currentValue, ok = m.contents[key]
42
>
if ok {
43
return currentValue, ok
44
}
46
>
return value, false
47
}
48
50
>
m.Lock()
51
>
defer m.Unlock()
52
>
m.contents[key] = value
53
>
}
54
55
func (m *SyncMap[K, V]) Delete(key K) {