Skip to content

Commit

Permalink
Mark _NameMap and supporting types as Sendable.
Browse files Browse the repository at this point in the history
I think this is the rest of the issues in apple#1560

This is the different approach discussed in apple#1564.
  • Loading branch information
thomasvl committed Mar 19, 2024
1 parent 033b0a2 commit 627d77b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Sources/SwiftProtobuf/NameMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,18 @@ public struct _NameMap: ExpressibleByDictionaryLiteral {
return jsonToNumberMap[n]
}
}

#if swift(>=5.5) && canImport(_Concurrency)
// The `_NameMap` (and supporting types) are only mutated during their initial
// creation, then for the lifetime of the a process they are constant. Swift
// 5.10 flags the generated `_protobuf_nameMap` usages as a problem
// (https://github.com/apple/swift-protobuf/issues/1560) so this silences those
// warnings since the usage has been deemed safe.
//
// https://github.com/apple/swift-protobuf/issues/1561 is also opened to revisit
// the `_NameMap` generally as it dates back to the days before Swift perferred
// the UTF-8 internal encoding.
extension _NameMap : Sendable {}
extension _NameMap.Name : @unchecked Sendable {}
extension InternPool : @unchecked Sendable {}
#endif

0 comments on commit 627d77b

Please sign in to comment.