diff --git a/Sources/System/FileDescriptor.swift b/Sources/System/FileDescriptor.swift index fbb7df30..7fa6eb18 100644 --- a/Sources/System/FileDescriptor.swift +++ b/Sources/System/FileDescriptor.swift @@ -473,3 +473,14 @@ extension FileDescriptor.OpenOptions /// A textual representation of the open options, suitable for debugging. public var debugDescription: String { self.description } } + +#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. +extension FileDescriptor: Sendable {} +extension FileDescriptor.AccessMode: Sendable {} +extension FileDescriptor.OpenOptions: Sendable {} +extension FileDescriptor.SeekOrigin: Sendable {} +#endif diff --git a/Sources/System/FilePath/FilePath.swift b/Sources/System/FilePath/FilePath.swift index 1aaa27ec..206b2bb2 100644 --- a/Sources/System/FilePath/FilePath.swift +++ b/Sources/System/FilePath/FilePath.swift @@ -69,3 +69,6 @@ extension FilePath { /*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/ extension FilePath: Hashable, Codable {} +#if compiler(>=5.5) && canImport(_Concurrency) +extension FilePath: Sendable {} +#endif diff --git a/Sources/System/FilePath/FilePathComponentView.swift b/Sources/System/FilePath/FilePathComponentView.swift index 959ff64c..b8324fd6 100644 --- a/Sources/System/FilePath/FilePathComponentView.swift +++ b/Sources/System/FilePath/FilePathComponentView.swift @@ -238,3 +238,8 @@ extension FilePath.ComponentView { #endif // DEBUG } } + +#if compiler(>=5.5) && canImport(_Concurrency) +extension FilePath.ComponentView: Sendable {} +extension FilePath.ComponentView.Index: Sendable {} +#endif diff --git a/Sources/System/FilePath/FilePathComponents.swift b/Sources/System/FilePath/FilePathComponents.swift index d6b043f3..19eca940 100644 --- a/Sources/System/FilePath/FilePathComponents.swift +++ b/Sources/System/FilePath/FilePathComponents.swift @@ -276,3 +276,9 @@ extension FilePath.Root { #endif } } + +#if compiler(>=5.5) && canImport(_Concurrency) +extension FilePath.Root: Sendable {} +extension FilePath.Component: Sendable {} +extension FilePath.Component.Kind: Sendable {} +#endif diff --git a/Sources/System/FilePermissions.swift b/Sources/System/FilePermissions.swift index 0780ee07..1465e3f7 100644 --- a/Sources/System/FilePermissions.swift +++ b/Sources/System/FilePermissions.swift @@ -175,3 +175,7 @@ extension FilePermissions /// A textual representation of the file permissions, suitable for debugging. public var debugDescription: String { self.description } } + +#if compiler(>=5.5) && canImport(_Concurrency) +extension FilePermissions: Sendable {} +#endif diff --git a/Sources/System/SystemString.swift b/Sources/System/SystemString.swift index a918a929..14651d52 100644 --- a/Sources/System/SystemString.swift +++ b/Sources/System/SystemString.swift @@ -288,6 +288,11 @@ extension SystemString { } } +#if compiler(>=5.5) && canImport(_Concurrency) +extension SystemChar: Sendable {} +extension SystemString: Sendable {} +#endif + // TODO: SystemString should use a COW-interchangable storage form rather // than array, so you could "borrow" the storage from a non-bridged String // or Data or whatever