FAQ
I don't use this package, so this question is just out of curiosity.
I would like to know "what" is "atomic", indeed.

I understand that an atomic operation will modify a 32 or 64 bits shared
variable with one machine instruction, and that no goroutine can see a
half-done modification.
So, "atomic" can mean that all bits are changed, or none of them.

But does "atomic" also mean that the change is immediately visible to other
goroutine ? or will the change only be visible to them "eventually" ?

Is the code below:

   var a int64

   atomic.AddInt64(&a, 1)

the same as:

   mutex.Lock()
   a += 1
   mutex.Unlock()

?


--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 21, '14 at 6:13p
activeNov 24, '14 at 7:45a
posts6
users6
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase