diff options
author | Rob Pike <r@golang.org> | 2014-10-27 17:08:50 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2014-10-27 17:08:50 -0700 |
commit | 7fd4f8bb2fdac9b6ebb048fccf8d34da9bd83a10 (patch) | |
tree | edb3c5e0b705b41b00971e0a971d3dd45a404393 /doc | |
parent | 9041655bd3fd1274135ba6bb10f536f2490b4cc2 (diff) | |
download | go-7fd4f8bb2fdac9b6ebb048fccf8d34da9bd83a10.tar.gz |
doc/go_mem.html: don't be clever
Add a short introductory section saying what most Go
programmers really need to know, which is that you
shouldn't have to read this document to understand
the behavior of your program.
LGTM=bradfitz, adg, tracey.brendan, iant, rsc, dsymonds
R=golang-codereviews, bradfitz, tracey.brendan, adg, iant, rsc, dsymonds
CC=golang-codereviews
https://codereview.appspot.com/158500043
Diffstat (limited to 'doc')
-rw-r--r-- | doc/go_mem.html | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/go_mem.html b/doc/go_mem.html index 2ea1ded7a..5dd48ff7f 100644 --- a/doc/go_mem.html +++ b/doc/go_mem.html @@ -21,6 +21,29 @@ reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine. </p> + +<h2>Advice</h2> + +<p> +Programs that modify data being simultaneously accessed by multiple goroutines +must serialize such access. +</p> + +<p> +To serialize access, protect the data with channel operations or other synchronization primitives +such as those in the <a href="/pkg/sync/"><code>sync</code></a> +and <a href="/pkg/sync/atomic/"><code>sync/atomic</code></a> packages. +</p> + +<p> +If you must read the rest of this document to understand the behavior of your program, +you are being too clever. +</p> + +<p> +Don't be clever. +</p> + <h2>Happens Before</h2> <p> |