From bc0c8b5918a60e7d5b9fe054e39e18f829370492 Mon Sep 17 00:00:00 2001
From: Mark McGranaghan
Date: Thu, 20 Jun 2013 08:11:53 -0700
Subject: [PATCH] rebuild
---
examples/atomic-counters/atomic-counters.go | 4 ++--
public/atomic-counters | 14 +++++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/examples/atomic-counters/atomic-counters.go b/examples/atomic-counters/atomic-counters.go
index 19ee445..842dfee 100644
--- a/examples/atomic-counters/atomic-counters.go
+++ b/examples/atomic-counters/atomic-counters.go
@@ -23,14 +23,14 @@ func main() {
// once a millisecond.
for i := 0; i < 50; i++ {
go func() {
- for {
+ for {
// To atomically increment the counter we
// use `AddUint64`, giving it the memory
// address of our `ops` counter with the
// `&` syntax.
atomic.AddUint64(&ops, 1)
- // Allow other goroutines to proceed.
+ // Allow other goroutines to proceed.
runtime.Gosched()
}
}()
diff --git a/public/atomic-counters b/public/atomic-counters
index 0139cb8..1102b1e 100644
--- a/public/atomic-counters
+++ b/public/atomic-counters
@@ -57,6 +57,7 @@ counters accessed by multiple goroutines.
import "fmt"
import "time"
import "sync/atomic"
+import "runtime"
@@ -97,7 +98,6 @@ once a millisecond.
for i := 0; i < 50; i++ {
go func() {
for {
- time.Sleep(time.Millisecond)
@@ -113,6 +113,18 @@ address of our ops
counter with the
atomic.AddUint64(&ops, 1)
+
+
+ |
+
+
+
+
+ Allow other goroutines to proceed.
+
+ |
+
+ runtime.Gosched()
}
}()
}
|