Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sendable conformances (except FileDescriptor) #115

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Sources/System/FileDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
// The decision on whether to make FileDescriptor Sendable or not
// is currently being discussed in https://github.com/apple/swift-system/pull/112
//@available(*, unavailable, message: "File descriptors are not completely thread-safe.")
//extension FileDescriptor: Sendable {}

extension FileDescriptor.AccessMode: Sendable {}
extension FileDescriptor.OpenOptions: Sendable {}
extension FileDescriptor.SeekOrigin: Sendable {}
#endif
3 changes: 3 additions & 0 deletions Sources/System/FilePath/FilePath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions Sources/System/FilePath/FilePathComponentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions Sources/System/FilePath/FilePathComponents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions Sources/System/FilePermissions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions Sources/System/SystemString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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