Skip to content

Commit 0dde2ec

Browse files
committed
sync: update comments for Once.done
Sync with CL 627777 and CL 666895.
1 parent 839da71 commit 0dde2ec

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sync/once.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Once struct {
2121
_ noCopy
2222

2323
// done indicates whether the action has been performed.
24-
// It is first in the struct because it is used in the hot path.
24+
// It is first (ignoring noCopy) in the struct because it is used in the hot path.
2525
// The hot path is inlined at every call site.
2626
// Placing done first allows more compact instructions on some architectures (amd64/386),
2727
// and fewer instructions (to calculate offset) on other architectures.
@@ -52,7 +52,7 @@ type Once struct {
5252
func (o *Once) Do(f func()) {
5353
// Note: Here is an incorrect implementation of Do:
5454
//
55-
// if o.done.CompareAndSwap(0, 1) {
55+
// if o.done.CompareAndSwap(false, true) {
5656
// f()
5757
// }
5858
//

0 commit comments

Comments
 (0)