Skip to content

Commit c6c23e3

Browse files
committed
Mark FileDescriptor Sendable conformance as unavailable
1 parent 0d05714 commit c6c23e3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Sources/System/FileDescriptor.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,13 @@ extension FileDescriptor.OpenOptions
475475
}
476476

477477
#if compiler(>=5.5) && canImport(_Concurrency)
478-
// File descriptors aren't necessarily safe to use across threads.
479-
// However, since they can be used in a safe way,
480-
// we do make them `Sendable` to not make it unnecessarily complicated to
481-
// use them across concurrency boundaries in a safe way.
478+
// Since some file descriptor operations aren't safe to use across threads,
479+
// we mark the Sendable conformance as unavailble.
480+
// To use file descriptors with operations that *are* thread-safe,
481+
// wrap them in an `@unchecked Sendable` type.
482+
@available(*, unavailable, message: "File descriptors are not completely thread-safe.")
482483
extension FileDescriptor: Sendable {}
484+
483485
extension FileDescriptor.AccessMode: Sendable {}
484486
extension FileDescriptor.OpenOptions: Sendable {}
485487
extension FileDescriptor.SeekOrigin: Sendable {}

0 commit comments

Comments
 (0)