Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
b6ad32b1
Commit
b6ad32b1
authored
Sep 20, 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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
doc/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>.
<h3>
Once
</h3>
<p>
The
<code>
once
</code>
package provides a safe mechanism for
initialization in the presence of multiple goroutines.
The
<code>
sync
</code>
package provides a safe mechanism for
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>
,
but only one will run
<code>
f()
</code>
, and the other calls block
until
<code>
f()
</code>
has returned.
...
...
@@ -293,6 +294,7 @@ In this program:
<pre>
var a string
var once sync.Once
func setup() {
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