liveBook · Manning

Busy-waiting loop

A busy-waiting loop repeatedly checks a condition while consuming processor resources rather than blocking or yielding while waiting.

How 4 Manning books explain it

100 Go Mistakes and How to Avoid Them

A busy loop is a repeated polling loop that continuously checks a condition instead of blocking until the condition may have changed.

How it is used
Highlights wasted CPU in concurrent Go code that polls shared state or repeatedly selects a closed channel.
How deep it goes
Traces both busy-wait mechanisms and contrasts them with condition-variable broadcast and nil-channel fixes.
Examples
Uses donation-goal listeners and a two-input channel merge to expose unnecessary looping.
What you can do after
Diagnose/debug polling and closed-channel loops, then replace them with blocking notification or nil-channel selection.

Read how 100 Go Mistakes and How to Avoid Them explains busy-waiting loop →

Software Design for Python Programmers

Busy waiting is repeatedly consuming execution time while waiting instead of relinquishing control to other threads.

How it is used
Simulates work that occupies a thread for a measured duration while demonstrating access to a shared resource.
How deep it goes
Defines the scheduling cost and implements a timed loop, but does not develop a general waiting strategy.
Examples
Uses technician meter-setting and logger read-and-log durations as concrete busy-waiting examples.
What you can do after
Build it from scratch using a timed Python loop that continues until elapsed time reaches the requested duration.

Read how Software Design for Python Programmers explains busy-waiting loop →

Effective Behavior-Driven Development

A pattern for handling an asynchronous result by repeatedly checking for completion until the result appears or a timeout occurs.

How it is used
Synchronizes automation code with asynchronous operations by repeatedly checking whether their results are ready.
How deep it goes
Explains polling, delay trade-offs, missed fast results, and timeout failures without specifying a tool-specific implementation.
Examples
Uses a file update to illustrate capturing resource status before an asynchronous request.
What you can do after
Apply polling with adjustable intervals, a timeout, and a baseline check for changes that may occur before waiting begins.

Read how Effective Behavior-Driven Development explains busy-waiting loop →

Rust in Action: Systems programming concepts and techniques

A spin loop repeatedly checks a condition while actively consuming CPU time instead of blocking execution.

How it is used
Uses active waiting for short pauses when sleep timing is insufficiently precise or timing sensitivity matters.
How deep it goes
Implements elapsed-time polling, thread yielding, joining, a broken borrowing variant, and scalability limits across CPU cores.
Examples
Demonstrates a 20-millisecond Rust wait, compares it with thread::sleep, and reproduces timing data across up to 1,000 threads.
What you can do after
Build it from scratch in Rust, benchmark it against sleep, and diagnose ownership errors when joining stored thread handlers.

Read how Rust in Action: Systems programming concepts and techniques explains busy-waiting loop →

What to know first

Related concepts

Questions about busy-waiting loop

What is busy-waiting loop?

A busy-waiting loop repeatedly checks a condition while consuming processor resources rather than blocking or yielding while waiting.

Which Manning books explain busy-waiting loop?

100 Go Mistakes and How to Avoid Them, Software Design for Python Programmers, Effective Behavior-Driven Development and Rust in Action: Systems programming concepts and techniques.

What should I know before learning busy-waiting loop?

Manning books that teach busy-waiting loop usually introduce CPU first.

What is the difference between busy-waiting loop and completed event pattern?

A busy-waiting loop repeatedly checks a condition while consuming processor resources rather than blocking or yielding while waiting. A pattern for waiting for an asynchronous operation to finish by receiving a completion event instead of repeatedly checking its status.

What is busy-waiting loop a kind of?

Busy-waiting loop is a kind of loop. A loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.