This commit is contained in:
Fangliding committed 2026-05-16 02:41:59 +08:00
1 parent c7672d004b
commit 6534bbf4b2
2 files changed
+10 -8

No files matched your search

+2 -2
View File
@@ -35,11 +35,11 @@ func (c *WeakCacheMap[K, V]) Store(key K, value *V) {
defer c.mu.Unlock()
weakPtr := weak.Make(value)
c.m[key] = weakPtr
runtime.AddCleanup(value, func(any) {
runtime.AddCleanup(value, func(struct{}) {
c.mu.Lock()
defer c.mu.Unlock()
if c.m[key] == weakPtr {
delete(c.m, key)
}
}, nil)
}, struct{}{})
}