Closed kr closed 12 years ago
I'm just learning Go, but:
AddUint64 atomically adds delta to *val and returns the new value.
So, that reads as if drops
is not being updated at all (but with StoreUint64
it was), so the following Fprintf
would output incorrect data. Or what am I misunderstanding here?
Hmm, the description is ambiguous, but AddUint64 definitely
modifies the value pointed at by the val
parameter.
Oh yes, I see how it can mean that as well. Confirmed, too!
You both might also find f3523a15a2e973db131b05e0806ba53176c84ec6 interesting.
Something could increment one of the counters after you read the old value and before you reset it to 0. If you instead atomically subtract the old value, then all events will still be counted.