Skip to content

Commit 3fc21bb

Browse files
committed
Mark FileDescriptor Sendable conformance as unavailable
1 parent dd086a0 commit 3fc21bb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Sources/System/FileDescriptor.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,11 @@ extension FileDescriptor.OpenOptions
476476
}
477477

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

485486
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)

0 commit comments

Comments
 (0)