This commit is contained in:
aozhiwei 2024-06-16 14:06:10 +08:00
parent 3ade5a2266
commit 47f75d8247

View File

@ -60,7 +60,12 @@ func (this *ConcurrentMap[T1, T2]) Store(key T1, value T2) {
this.kvHash.Store(key, value)
}
func (this *ConcurrentMap[T1, T2]) Swap(key T1, value T2) (T2, bool) {
func (this *ConcurrentMap[T1, T2]) Swap(key T1, value T2) (*T2, bool) {
previous, loaded := this.kvHash.Swap(key, value)
return previous.(T2), loaded
if loaded {
tmpPrevious := previous.(T2)
return &tmpPrevious, loaded
} else {
return nil, loaded
}
}