修复safety.map flush bug
This commit is contained in:
parent
e978e86304
commit
00e42c2d56
@ -320,7 +320,9 @@ func (e *entry[V]) delete(px unsafe.Pointer) (value V, ok bool) {
|
||||
|
||||
func (m *Map[K, V]) Flush() {
|
||||
m.mu.Lock()
|
||||
m.missLocked()
|
||||
m.dirty = nil
|
||||
m.read.Store(readOnly[K, V]{m: m.dirty})
|
||||
m.misses = 0
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,12 @@ func TestMap_Load(t *testing.T) {
|
||||
}
|
||||
p := taskPools.NewPools(10)
|
||||
var a0, a1 []int
|
||||
for i := 0; i < 5000; i++ {
|
||||
v := number.Rand(0, 1)
|
||||
for i := 0; i < 15000; i++ {
|
||||
v := number.Rand(0, 2)
|
||||
if 1 == v {
|
||||
a1 = append(a1, 1)
|
||||
} else if 0 == v {
|
||||
m.Flush()
|
||||
} else {
|
||||
a0 = append(a0, 0)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user