patch sync/atomic; typepatch fix (don't change types)

This commit is contained in:
xushiwei
2024-06-17 03:38:01 +08:00
parent 68a63bb280
commit b4794dc541
9 changed files with 328 additions and 132 deletions

View File

@@ -5,6 +5,20 @@ import (
)
func main() {
var v int64 = 100
println(atomic.AddInt64(&v, 1))
var v int64
atomic.StoreInt64(&v, 100)
println("store:", atomic.LoadInt64(&v))
ret := atomic.AddInt64(&v, 1)
println("ret:", ret, "v:", v)
swp := atomic.CompareAndSwapInt64(&v, 100, 102)
println("swp:", swp, "v:", v)
swp = atomic.CompareAndSwapInt64(&v, 101, 102)
println("swp:", swp, "v:", v)
ret = atomic.AddInt64(&v, -1)
println("ret:", ret, "v:", v)
}