liveBook · Manning

Blocking

As explained in Go in Action, Second Edition

A blocking I/O operation prevents the calling execution flow from progressing until input or output completes.

A blocking I/O operation holds the calling execution flow until input or output completes. Network and disk waits can leave useful work unperformed, making concurrency valuable when tasks are independent. section 9.1

A practical Go design uses blocking operations as work that can run independently:

  • Fetch RSS feeds concurrently so waiting on one network request does not prevent other feed retrievals. section 9.1

Concurrent RSS fetching

Define printFeedTitle to call gofeed.ParseURL, then launch it with go for each feed URL. The example uses a timed sleep to keep the process alive while fetching completes.

How Go in Action, Second Edition covers it

How deep it goes
Demonstrates synchronous ParseURL calls and moves them into goroutines, without detailing blocking internals or synchronization mechanisms.
Examples
Uses New York Times and BBC RSS requests parsed through gofeed.ParseURL.
What you can do after
Apply it via Go goroutines to overlap independent network or disk waits with other work.
How it connects
Connects blocking I/O with concurrency, goroutines, network requests, RSS feeds, and shared data.

Also explained in

Compare how 9 books explain blocking →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Action, Second Edition. The section links point to the parts of the book it draws on.