Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
b6ad32b1
Commit
b6ad32b1
authored
Sep 19, 2010
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc/go_mem.html: update location of "once".
Fixes #1118. R=rsc CC=golang-dev
https://golang.org/cl/2225044
parent
c8b3d029
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
go_mem.html
doc/go_mem.html
+4
-2
No files found.
doc/go_mem.html
View file @
b6ad32b1
...
@@ -276,8 +276,9 @@ before the <i>n</i>+1'th call to <code>l.Lock</code>.
...
@@ -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:
...
@@ -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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment