The Sendable Protocol
Mark types safe to cross concurrency domains.
What Sendable Means
Sendable is a marker protocol. A type that conforms promises it is safe to share across concurrency domains without introducing data races.
It has no methods; it is a compiler-checked guarantee about thread safety.
protocol Sendable {}Value Types Are Often Sendable
Structs and enums whose stored properties are all Sendable can conform automatically.
Because values are copied when passed, each task gets its own independent copy.
struct User: Sendable {
let id: Int
let name: String
}All lessons in this course
- The Data Race Problem
- The Sendable Protocol
- Actor Isolation and nonisolated
- Migrating to Strict Concurrency