liveBook · Manning

Asynchronous programming

As explained in Rust in Action: Systems programming concepts and techniques

Asynchronous programming is a programming model in which externally occurring events influence the order of control-flow execution.

Asynchronous programming handles situations where events outside the program determine which control-flow step executes next. These events commonly come from I/O devices or functions completing in another thread. section 10.5

Asynchronous programming connects several execution ideas:

  • Non-blocking I/O lets a thread continue executing while it waits for network or device data. section 10.5
  • Coroutines switch tasks within one thread, with the program rather than the operating system controlling the switch. section 10.5
  • Concurrency means multiple tasks can run at the same time; parallelism means multiple threads execute on multiple CPUs. section 10.5

Waiting for network data

A normally blocking thread is unscheduled while it waits for network input. With non-blocking I/O, data from multiple sockets can be queued and polled together, while asynchronous events determine what runs next. section 10.5

Figure 10.5 Trade-offs relating to different forms of task isolation in computing. In general terms, increasing the isolation level increases the overhead.

Compare task-isolation choices and their overhead: greater isolation generally increases overhead. section 10.5

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Defines the model, distinguishes related execution terms, and explains system-call and context-switch implications.
Examples
Uses network sockets, device-driver readiness signals, queued I/O, and functions returning in another thread.
What you can do after
Evaluate/understand why asynchronous execution can improve I/O-heavy runtime performance while increasing developer complexity.
How it connects
Connects concurrency, parallelism, coroutines, threads, non-blocking I/O, system calls, and context switches.

Also explained in

Compare how 28 books explain asynchronous programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.