On Sun, May 26, 2019 at 4:03 PM Sotirios Mantziaris
<smantzia...@gmail.com> wrote:

> Let's assume that the string field Name has the value `Mr. Smith` and we 
> change this to  `Mr. Anderson` in the goroutine, what are the possible values 
> that i could bet on a read?
>
> If these are either `Mr. Smith` or `Mr. Anderson` i am very ok with that 
> because i want the value to be eventually consistent.

That would be the only possible outcomes iff a multi word value is
updated atomically.

> If there is another possible outcome then i need to synchronize the access 
> and refactor a lot.

Any outcome is possible with a data race. One of those that are often
seen in practices is, obviously, `Mr. Ander`. Another is that the app
will segfault. Also, the Go memory model does not guarantee one
goroutine will _ever_ observe a change made by a different goroutine
concurrently but without proper synchronization. The compiler if free
to consider all values not explicitly mutated by a code path to never
change without synchronization.

tl;dr: There's no safe way to ignore a data race.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-Wzg2mEw0jRfFJSGm61GToHUEDYVAXMe0_bkZaFsqFmLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to