1
This commit is contained in:
parent
db5e615704
commit
ccfa6c4f99
8
sync.go
8
sync.go
@ -2,6 +2,7 @@ package q5
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type ConcurrentMap[T1 string | int | int32 | int64, T2 any] struct {
|
||||
@ -69,3 +70,10 @@ func (this *ConcurrentMap[T1, T2]) Swap(key T1, value T2) (*T2, bool) {
|
||||
return nil, loaded
|
||||
}
|
||||
}
|
||||
|
||||
func AtomicStoreInt64WhenGreater(srcVal *int64, trgVal *int64) {
|
||||
tmpVal := atomic.LoadInt64(srcVal)
|
||||
if tmpVal > *trgVal {
|
||||
atomic.StoreInt64(trgVal, tmpVal)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user