Overview - Nonisolated methods
What is it?
Nonisolated methods in Swift are functions inside an actor that can be called without switching to the actor's isolated context. They allow access to data or behavior that is safe to use concurrently without waiting for the actor's exclusive access. This means these methods run without the usual actor synchronization, making them faster for certain tasks. They are marked with the 'nonisolated' keyword to show they don't require actor isolation.
Why it matters
Actors in Swift protect data by isolating it, but sometimes you want to provide methods that are safe to call from anywhere without waiting. Without nonisolated methods, every call to an actor's method would require switching contexts, which can slow down your program. Nonisolated methods let you share safe, read-only, or stateless behavior efficiently, improving performance and responsiveness in concurrent apps.
Where it fits
Before learning nonisolated methods, you should understand Swift actors and actor isolation, including how actors protect data with concurrency. After this, you can explore advanced concurrency topics like global actors, actor reentrancy, and how to design safe concurrent APIs using nonisolated methods.