Summary
In this chapter, we examined structured concurrency in Swift and explained why this new modern approach is preferrable to the old ones. We examined the basic components of structured concurrency, including async
/await
, async let
, tasks, task groups, and asynchronous sequences and streams. You were introduced to the preferred way to synchronize tasks, actors, including the MainActor
and user-defined global actors. Finally, we learned how to use the new structured approach with old code that uses old concurrency models.
In the next chapter, we will introduce the SwiftData framework.