Chapter 15. Concurrency with isolates
This chapter covers
- Spawning new function isolates
- Passing messages between isolates
- Loading Dart code dynamically
- Using isolates for batch processing
Modern computer hardware provides more processing power than ever before, whether it’s in a server room serving thousands of requests per minute or in your pocket as a mobile phone or tablet. Rather than providing ever-increasing processor speeds, chip designers have achieved this improvement by adding more CPU cores. To take advantage of this greater processing power, web application design also needs to be able to scale out to use the additional CPU cores.
Earlier in this book, we discussed how Dart code runs in a single thread but can call out to asynchronous APIs, such as accessing the filesystem or external servers. In the browser, applications use async APIs to perform AJAX-type requests for data from the server. But your Dart code still runs in a single thread and will take advantage of only a single CPU core. This is a design constraint imposed by the goal to allow Dart to be converted to JavaScript, which is also single-threaded.