Chapter 8: Designing for Concurrency
Concurrent design patterns help us to manage many tasks at once and structure their life cycle. By using these patterns efficiently, we can avoid problems such as resource leaks and deadlocks.
In this chapter, we'll discuss concurrent design patterns and how they are implemented in Kotlin. To do this, we'll be using the building blocks from previous chapters: coroutines, channels, flows, and concepts from functional programming.
We will be covering the following topics in this chapter:
- Deferred value
- Barrier
- Scheduler
- Pipeline
- Fan out
- Fan in
- Racing
- Mutex
- Sidekick channel
After completing this chapter, you'll be able to work with asynchronous values efficiently, coordinate the work of different coroutines, and distribute and aggregate work, as well as have the tools needed to resolve any concurrency problems that may arise in the process.