November 2017: Concurrency

Meetup #44. Please RSVP at Meetup.

We get started at 6:30 pm.

Sponsors

Venue provided by Startup Edmonton.

Food sponsored by Bellstone Engineering.

Talks

Concurrency in Go: An Introduction to Channels

Tobias Renwick gave an introduction to concurrency in Go using goroutines and channels, built around the Go proverb "do not communicate by sharing memory; instead, share memory by communicating." The talk covered primitives like sync.Mutex, sync.RWMutex, and sync.WaitGroup, and contrasted unbuffered (synchronous) channels with buffered ones whose capacity acts as a queue. The example code showed the classic data race — two goroutines incrementing a shared counter and producing the wrong result — then fixed it with a mutex and with a handshake channel that serializes access. It finished with a producer/consumer pipeline that produces numbers, adds and multiplies pairs, and consumes the result, demonstrating that fully asynchronous code can still be deterministic and race-free.

Key points:

  • Prefer sharing memory by communicating over communicating by sharing memory.
  • Channels can be unbuffered (handshake) or buffered (queue with capacity).
  • sync.Mutex/RWMutex guard shared state; WaitGroup waits for goroutines.
  • Uncoordinated goroutines cause race conditions.
  • A channel handshake can serialize access to shared data.
  • Compose pipelines from produce → transform → consume stages.
  • Closing a channel signals downstream that no more values are coming.

Tobias Renwick (code)

News

Events