diff --git a/examples/stateful-goroutines/stateful-goroutines.hash b/examples/stateful-goroutines/stateful-goroutines.hash index a3eefdd..1d50d4a 100644 --- a/examples/stateful-goroutines/stateful-goroutines.hash +++ b/examples/stateful-goroutines/stateful-goroutines.hash @@ -1,2 +1,2 @@ -13c5072f2ccb7afb85b8c7ea9a97f94423aef8de -2YrrJo4H6W +0005e59edec522954b80e46279a207aa7f80df59 +8Qxa8MHXAv diff --git a/public/stateful-goroutines b/public/stateful-goroutines index 485ec2f..9fa5dc2 100644 --- a/public/stateful-goroutines +++ b/public/stateful-goroutines @@ -46,7 +46,7 @@ by exactly 1 goroutine.

- +
package main
 
@@ -112,22 +112,7 @@ goroutine to respond.

-

The state will be a map as in the previous -example.

- - - - -
    var state = make(map[int]int)
-
- - - - - - -

Also as before we’ll count how many operations we -perform.

+

As before we’ll count how many operations we perform.

@@ -156,19 +141,33 @@ respectively.

-

Here is the goroutine that owns the state. This -goroutine repeatedly selects on the reads and -writes channels, responding to requests as they -arrive. A response is executed by first performing -the requested operation and then sending a value -on the response channel resp to indicate success -(and the desired value in the case of reads).

+

Here is the goroutine that owns the state, which +is a map as in the previous example but now private +to the stateful goroutine. This goroutine repeatedly +selects on the reads and writes channels, +responding to requests as they arrive. A response +is executed by first performing the requested +operation and then sending a value on the response +channel resp to indicate success (and the desired +value in the case of reads).

    go func() {
-        for {
+        var state = make(map[int]int)
+
+ + + + + + + + + + +
        for {
             select {
             case read := <-reads:
                 read.resp <- state[read.key]