From 070261e43dd76574102b4e4dee8812cb3fce0a90 Mon Sep 17 00:00:00 2001
From: Himanshu Patel
Date: Sun, 27 Nov 2022 06:13:29 +0000
Subject: [PATCH] Update comment in Atomic Counter
Type: Refactoring
Adding the text message from atomic-counters.sh file in examples
to the comment in the code file.
---
examples/atomic-counters/atomic-counters.go | 4 ++++
examples/atomic-counters/atomic-counters.hash | 4 ++--
public/atomic-counters | 10 +++++++---
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/examples/atomic-counters/atomic-counters.go b/examples/atomic-counters/atomic-counters.go
index 046a347..e96752d 100644
--- a/examples/atomic-counters/atomic-counters.go
+++ b/examples/atomic-counters/atomic-counters.go
@@ -34,6 +34,10 @@ func main() {
// use `AddUint64`, giving it the memory
// address of our `ops` counter with the
// `&` syntax.
+
+ // Also try by replacing `atomic.AddUint64(&ops, 1)`
+ // with `ops++` and see the difference in output each
+ // time we run the example
atomic.AddUint64(&ops, 1)
}
wg.Done()
diff --git a/examples/atomic-counters/atomic-counters.hash b/examples/atomic-counters/atomic-counters.hash
index f4c10e6..d4c19e7 100644
--- a/examples/atomic-counters/atomic-counters.hash
+++ b/examples/atomic-counters/atomic-counters.hash
@@ -1,2 +1,2 @@
-7b491b40d56a77b01d8e2bd08366de081a4e8d99
-j-14agntvEO
+411d812735b41f901f82f31f55e74895dc837574
+pWwgacr1iKb
diff --git a/public/atomic-counters b/public/atomic-counters
index 6548101..84ab63a 100644
--- a/public/atomic-counters
+++ b/public/atomic-counters
@@ -46,7 +46,7 @@ counters accessed by multiple goroutines.
- 
+ 
package main
|
@@ -139,11 +139,15 @@ address of our ops
counter with the
-
+ Also try by replacing atomic.AddUint64(&ops, 1)
+with ops++ and see the difference in output each
+time we run the example
+
|
- atomic.AddUint64(&ops, 1)
+
+ atomic.AddUint64(&ops, 1)
}
wg.Done()
}()
|