[go-nuts] Understanding the mutex.TryLock return false when the mutex is unlocked based on the memory model

2022-09-08 Thread Benz
There are two cases in mutex.TryLock could return false - the lock is currently held by another goroutine. - the lock is not held but the mutex is in starvation mode; i.e., the lock will be handed off to the next waiter

[go-nuts] How to use atomic.Int64?

2022-09-01 Thread Benz
Since go `1.19`, the [`atomic.Int64`](https://github.com/golang/go/blob/go1.19/src/sync/atomic/type.go#L82) was added ```go type Int64 struct { _ noCopy _ align64 v int64 } ``` There is one additional [`align64`](https://github.com/golang/go/blob/go1.19/src/sync/atomic/type.go#L1