1
This commit is contained in:
parent
3ade5a2266
commit
47f75d8247
9
sync.go
9
sync.go
@ -60,7 +60,12 @@ func (this *ConcurrentMap[T1, T2]) Store(key T1, value T2) {
|
|||||||
this.kvHash.Store(key, value)
|
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)
|
previous, loaded := this.kvHash.Swap(key, value)
|
||||||
return previous.(T2), loaded
|
if loaded {
|
||||||
|
tmpPrevious := previous.(T2)
|
||||||
|
return &tmpPrevious, loaded
|
||||||
|
} else {
|
||||||
|
return nil, loaded
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user