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



























