var sequence int64
// writer
for i := sequence; i < max; i++ {
doSomethingWithSequence(i)
sequence = i
}
// reader
for {
doSomeOtherThingWithSequence(sequence)
}
reordering (for the writer, updating sequence
happens before doSomething
) could happen, but I can live with that.
sequence
is not properly aligned in memory so the reader might observe a partially updated sequence. Running on (recent kernel) linux with x86_64, can we rule that out?
go compiler 'cleverly optimizes' the reader, so the access to i
never goes to memory but 'stayed' in a register. Is that possible in go?
Anything else?
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mechanical-sympathy/31e1ab4e-8581-45e9-9419-6f7f80c41281%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.