
Consistently use `time.Sleep`, instead of `runtime.Gosched`, to ensure all goroutines can make progress. `Gosched` wasn't working in the playground (ref #149). Also stop trying to compare operation rates. This was tenuous given e.g. how short the programs ran for, and with the `Sleep`s we now expect the rates to be similar anyways.
11 lines
312 B
Bash
11 lines
312 B
Bash
# Running the program shows that we executed about
|
|
# 90,000 total operations against our `mutex`-synchronized
|
|
# `state`.
|
|
$ go run mutexes.go
|
|
readOps: 83285
|
|
writeOps: 8320
|
|
state: map[1:97 4:53 0:33 2:15 3:2]
|
|
|
|
# Next we'll look at implementing this same state
|
|
# management task using only goroutines and channels.
|