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 18, 2024
1 parent b3c2279 commit 688b640
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/SwiftProtobuf/NameMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,16 @@ public struct _NameMap: ExpressibleByDictionaryLiteral {
return jsonToNumberMap[n]
}
}

// 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 {}

0 comments on commit 688b640

Please sign in to comment.