Skip to content

Commit c554b62

Browse files
committed
Use a type that's actually not sendable.
Incorporates feedback from Kyle Murray <[email protected]>.
1 parent 3de3e5c commit c554b62

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

TSPL.docc/LanguageGuide/Concurrency.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,14 +1116,25 @@ overriding an implicit conformance to the `Sendable` protocol,
11161116
use an extension:
11171117

11181118
```swift
1119-
struct NonsendableTemperatureReading {
1120-
var measurement: Int
1119+
struct FileDescriptor {
1120+
let rawValue: CInt
11211121
}
11221122

11231123
@available(*, unavailable)
1124-
extension NonsendableTemperatureReading: Sendable { }
1124+
extension FileDescriptor: Sendable { }
11251125
```
11261126

1127+
<!--
1128+
The example above is abbreviated from a Swift System API.
1129+
https://github.com/apple/swift-system/blob/main/Sources/System/FileDescriptor.swift
1130+
-->
1131+
1132+
The code above shows part of a wrapper around POSIX file descriptors.
1133+
Even though interface for file descriptors uses integers
1134+
to identify and interact with open files,
1135+
and integer values are sendable,
1136+
a file descriptor isn't safe to send across concurrency domains.
1137+
11271138
<!--
11281139
- test: `suppressing-implied-sendable-conformance`
11291140

0 commit comments

Comments
 (0)