Explores whether a stateless actor in Swift has any practical value. Covers three main use cases: using an actor as a Sendable, non-MainActor type (e.g., NetworkClient), defining a custom global actor for background work, and using custom executor actors to integrate Swift concurrency with existing queue-based systems like DispatchSerialQueue. Also discusses using actors to serialize access to external state like the file system. Contrasts actor-based approaches with struct + @concurrent alternatives, highlighting trade-offs around serial execution, protocol compatibility, and Sendable requirements. Concludes that stateless actors can be valid but should be used intentionally with a clear rationale.

7m read timeFrom massicotte.org
Post cover image
Table of contents
Easy non-MainActor typesThe background actorCustom executor actorsThe file systemThe first rule of actors
2 Impressions