Skip to content

Commit

Permalink
Mark FileDescriptor Sendable conformance as unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Jul 10, 2023
1 parent dd086a0 commit 3fc21bb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Sources/System/FileDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,11 @@ extension FileDescriptor.OpenOptions
}

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

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

0 comments on commit 3fc21bb

Please sign in to comment.