From d998c9717d621a2042a5a82b1c02ae425d7b94e2 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 a152b098..4b876a32 100644 --- a/Sources/System/FileDescriptor.swift +++ b/Sources/System/FileDescriptor.swift @@ -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 {}