If you captured any state before doing some async work in your actor, then by the time your task is resumed, your captured state may be stale. This is what actor reentrancy is about. You should understand your captured state may have became stale. Because of that, you should avoid capturing things that are subject to change before your task is suspended. Only retrieve values after your task is resumed....
What Is a Suspension Point In Swift?
A suspension point doesnโt mean the current thread is blocked. Nor it means the current actor is blocked. All it means is that the current task / function is blocked / suspended / waiting for an asynchronous task to finish.
@MainActor func foo() async { doA() let b = await doB() doC() } When you get to doB(), then the MainActor / Main Thread are not suspended. Other tasks can be enqueued and executed on the main thread....
Swift Actors: few random notes
This post isnโt meant to explain how actors work. Rather just elaborate a few tiny details.
Iโm often curious about the origins of things. How people met, dated or how they began their careers or founded their companies. Similarly about namings, understanding the context often gives you a foundational understanding. I give feedback in Pull Requests about variable and type names or seek advice through code-review channels. First time it occurred was when someone explained that the reduce function means โhow you jam and reduce an entire array into a single valueโ....