From 3fc21bb7789dbf7e1db75e0ace47323ed476eec6 Mon Sep 17 00:00:00 2001 From: Florian Friedrich Date: Mon, 7 Nov 2022 10:57:43 +0100 Subject: [PATCH] Mark FileDescriptor Sendable conformance as unavailable --- Sources/System/FileDescriptor.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/System/FileDescriptor.swift b/Sources/System/FileDescriptor.swift index fed4fa96..cfb4f518 100644 --- a/Sources/System/FileDescriptor.swift +++ b/Sources/System/FileDescriptor.swift @@ -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, *)