mirror of
https://github.com/golang/go
synced 2024-11-21 21:04:41 -07:00
doc/go_mem.html: update location of "once".
Fixes #1118. R=rsc CC=golang-dev https://golang.org/cl/2225044
This commit is contained in:
parent
c8b3d02939
commit
b6ad32b183
@ -276,8 +276,9 @@ before the <i>n</i>+1'th call to <code>l.Lock</code>.
|
|||||||
<h3>Once</h3>
|
<h3>Once</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The <code>once</code> package provides a safe mechanism for
|
The <code>sync</code> package provides a safe mechanism for
|
||||||
initialization in the presence of multiple goroutines.
|
initialization in the presence of multiple goroutines
|
||||||
|
through the use of the <code>Once</code> type.
|
||||||
Multiple threads can execute <code>once.Do(f)</code> for a particular <code>f</code>,
|
Multiple threads can execute <code>once.Do(f)</code> for a particular <code>f</code>,
|
||||||
but only one will run <code>f()</code>, and the other calls block
|
but only one will run <code>f()</code>, and the other calls block
|
||||||
until <code>f()</code> has returned.
|
until <code>f()</code> has returned.
|
||||||
@ -293,6 +294,7 @@ In this program:
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
var a string
|
var a string
|
||||||
|
var once sync.Once
|
||||||
|
|
||||||
func setup() {
|
func setup() {
|
||||||
a = "hello, world"
|
a = "hello, world"
|
||||||
|
Loading…
Reference in New Issue
Block a user