Chapter 8

Goroutines and Channels

Concurrency with goroutines and channels

✓ Launch goroutines ✓ Use channels ✓ Select statement
1
Cake
Package cake provides a simulation of a concurrent cake shop with numerous parameters. Use this command to run the benchmarks: $ go test -bench=. gopl.io/ch8/cake
p.234 +20 XP advanced
2
Chat
Chat is a server that lets clients chat with each other.
p.254 +20 XP advanced
3
Clock1
Clock1 is a TCP server that periodically writes the time.
p.219 +20 XP advanced
4
Clock2
Clock is a TCP server that periodically writes the time.
p.222 +20 XP advanced
5
Countdown1
Countdown implements the countdown for a rocket launch.
p.244 +20 XP advanced
6
Countdown2
Countdown implements the countdown for a rocket launch.
p.244 +20 XP advanced
7
Countdown3
Countdown implements the countdown for a rocket launch.
p.246 +20 XP advanced
8
Crawl1
Crawl1 crawls web links starting with the command-line arguments. This version quickly exhausts available file descriptors due to excessive concurrent calls to links.Extract. Also, it never terminates because the worklist is never closed.
p.240 +20 XP advanced
9
Crawl2
Crawl2 crawls web links starting with the command-line arguments. This version uses a buffered channel as a counting semaphore to limit the number of concurrent calls to links.Extract.
p.241 +20 XP advanced
10
Crawl3
Crawl3 crawls web links starting with the command-line arguments. This version uses bounded parallelism. For simplicity, it does not address the termination problem.
p.243 +20 XP advanced
11
Du1
The du1 command computes the disk usage of the files in a directory.
p.247 +20 XP advanced
12
Du2
The du2 command computes the disk usage of the files in a directory.
p.249 +20 XP advanced
13
Du3
The du3 command computes the disk usage of the files in a directory.
p.250 +20 XP advanced
14
Du4
The du4 command computes the disk usage of the files in a directory.
p.251 +20 XP advanced
15
Netcat1
Netcat1 is a read-only TCP client.
p.221 +20 XP advanced
16
Netcat2
Netcat is a simple read/write client for TCP servers.
p.223 +20 XP advanced
17
Netcat3
Netcat is a simple read/write client for TCP servers.
p.227 +20 XP advanced
18
Pipeline1
Pipeline1 demonstrates an infinite 3-stage pipeline.
p.228 +20 XP advanced
19
Pipeline2
Pipeline2 demonstrates a finite 3-stage pipeline.
p.229 +20 XP advanced
20
Pipeline3
Pipeline3 demonstrates a finite 3-stage pipeline with range, close, and unidirectional channel types.
p.231 +20 XP advanced
21
Reverb1
Reverb1 is a TCP server that simulates an echo.
p.223 +20 XP advanced
22
Reverb2
Reverb2 is a TCP server that simulates an echo.
p.224 +20 XP advanced
23
Spinner
Spinner displays an animation while computing the 45th Fibonacci number.
p.218 +20 XP advanced
24
Thumbnail
The thumbnail command produces thumbnails of JPEG files whose names are provided on each line of the standard input. The "+build ignore" tag (see p.295) excludes this file from the thumbnail package, but it can be compiled as a command and run like this: Run with: $ go run $GOPATH/src/gopl.io/ch8/thumbnail/main.go foo.jpeg ^D
+20 XP advanced