From 6d8aa9b50a20c4caa93b7e41f86aeb6961351c59 Mon Sep 17 00:00:00 2001
From: Eli Bendersky
package main
type writeOp struct {
key int
val int
resp chan bool
@@ -121,8 +132,8 @@ respectively.
reads := make(chan *readOp)
- writes := make(chan *writeOp)
+ reads := make(chan readOp)
+ writes := make(chan writeOp)
resp
channel.
for r := 0; r < 100; r++ {
go func() {
for {
- read := &readOp{
+ read := readOp{
key: rand.Intn(5),
resp: make(chan int)}
reads <- read
@@ -200,7 +211,7 @@ approach.
for w := 0; w < 10; w++ {
go func() {
for {
- write := &writeOp{
+ write := writeOp{
key: rand.Intn(5),
val: rand.Intn(100),
resp: make(chan bool)}
From f99adfc228194d44bab6f736a1a118839cff7c10 Mon Sep 17 00:00:00 2001
From: Eli Bendersky
Date: Tue, 4 Jun 2019 16:27:55 -0700
Subject: [PATCH 2/2] Keep the two structs together for presentation
---
.../stateful-goroutines/stateful-goroutines.go | 1 -
.../stateful-goroutines/stateful-goroutines.hash | 4 ++--
public/stateful-goroutines | 15 ++-------------
3 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/examples/stateful-goroutines/stateful-goroutines.go b/examples/stateful-goroutines/stateful-goroutines.go
index 59655bb..cb8b347 100644
--- a/examples/stateful-goroutines/stateful-goroutines.go
+++ b/examples/stateful-goroutines/stateful-goroutines.go
@@ -28,7 +28,6 @@ type readOp struct {
key int
resp chan int
}
-
type writeOp struct {
key int
val int
diff --git a/examples/stateful-goroutines/stateful-goroutines.hash b/examples/stateful-goroutines/stateful-goroutines.hash
index 4956f93..1f3eb48 100644
--- a/examples/stateful-goroutines/stateful-goroutines.hash
+++ b/examples/stateful-goroutines/stateful-goroutines.hash
@@ -1,2 +1,2 @@
-330fde708b006d5571f9b94e7a63b4fead62bd36
-DxITfgl__z9
+956afe7524b492b2e85f8320c70f180c448a764a
+saQTLpdIgp2
diff --git a/public/stateful-goroutines b/public/stateful-goroutines
index 144f1e9..f684680 100644
--- a/public/stateful-goroutines
+++ b/public/stateful-goroutines
@@ -34,7 +34,7 @@ by exactly 1 goroutine.
-
+
package main
@@ -76,18 +76,7 @@ goroutine to respond.
key int
resp chan int
}
-
-
-
-
type writeOp struct {
+type writeOp struct {
key int
val int
resp chan bool