whats new in concurrency and sendable
Generated on 7/31/2024
1 search
What's New in Concurrency and Sendable
Data Race Safety
Swift 6 introduces significant improvements in data race safety, ensuring that your concurrent code is safe and free from data races by default. This is achieved through complete concurrency checking, which turns potential data race issues into compile-time errors, thereby improving the security and reliability of your app.
Sendable
A key concept in Swift's concurrency model is the Sendable
protocol. A type is considered sendable if it can be safely shared across different concurrency domains without causing data races. Swift 6 enhances the handling of sendable types by:
- Automatic Sendability for Internal Types: Swift automatically considers internal types as sendable if they meet the criteria.
- Explicit Sendability for Public Types: For public types, you need to explicitly mark them as sendable. This is because marking a type as sendable is a guarantee to your clients that the type contains no mutable state, which might change in the future.
Actors
Actors are a new feature in Swift that help manage concurrency by encapsulating mutable state and ensuring that only one task can access the state at a time. This serialization of access helps prevent data races.
Low-Level Synchronization Primitives
Swift 6 introduces new low-level synchronization primitives, such as atomics, which provide efficient, lock-free implementations for managing shared state.
Migration to Swift 6
Migrating to Swift 6 involves adopting the new language mode, which can be done module by module. This allows you to incrementally update your codebase and take advantage of the new concurrency features without having to refactor everything at once.
Relevant Sessions
Chapter Markers
-
What’s new in Swift
- Swift 6 language mode and data-race safety
- Low-level synchronization primitives
-
Migrate your app to Swift 6
- Swift 6 and data-race safety
- Adopting concurrency features
- Enabling complete checking in CoffeeKit
-
A Swift Tour: Explore Swift’s features and design
- Concurrency
For more detailed information, you can refer to the specific sessions and their chapters mentioned above.
Migrate your app to Swift 6
Experience Swift 6 migration in action as we update an existing sample app. Learn how to migrate incrementally, module by module, and how the compiler helps you identify code that’s at risk of data races. Discover different techniques for ensuring clear isolation boundaries and eliminating concurrent access to shared mutable state.
What’s new in Swift
Join us for an update on Swift. We’ll briefly go through a history of Swift over the past decade, and show you how the community has grown through workgroups, expanded the package ecosystem, and increased platform support. We’ll introduce you to a new language mode that achieves data-race safety by default, and a language subset that lets you run Swift on highly constrained systems. We’ll also explore some language updates including noncopyable types, typed throws, and improved C++ interoperability.
A Swift Tour: Explore Swift’s features and design
Learn the essential features and design philosophy of the Swift programming language. We’ll explore how to model data, handle errors, use protocols, write concurrent code, and more while building up a Swift package that has a library, an HTTP server, and a command line client. Whether you’re just beginning your Swift journey or have been with us from the start, this talk will help you get the most out of the language.