On Tuesday, 4 October 2016 13:32:03 UTC-4, Ahmed (OneOfOne) W. wrote:
>
> Some of our code uses something like:
>
> type Dummy struct {
> closed int64
> }
>
> func(d *Dummy) IsClosed() bool {
> return atomic.LoadInt64(&d.closed) == 1
> }
>
> func(d *Dummy) Close() error {
> if !atomic.CompareAndSwa
A goroutine might try to Close while another is checking IsClosed, it is
racy no matter how you implement it.
Go with the atomic load.
On Tuesday, October 4, 2016 at 7:32:03 PM UTC+2, Ahmed (OneOfOne) W. wrote:
>
> Some of our code uses something like:
>
> type Dummy struct {
> closed int64
> }
>