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 Dec 1, 2022
1 parent 753307a commit d998c97
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 @@ -475,10 +475,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 {}

extension FileDescriptor.AccessMode: Sendable {}
Expand Down

0 comments on commit d998c97

Please sign in to comment.