Skip to content

Commit

Permalink
Adopt strict concurrency in _NIODataStructures
Browse files Browse the repository at this point in the history
Motivation:

We're slowly adopting strict concurrency in NIO. This
is next.

Modifications:

- Make TinyArray's Iterator Sendable
- Add the stict concurrency flags

Result:

One small step for NIO, one giant leap for NIOkind.
  • Loading branch information
Lukasa committed Aug 9, 2024
1 parent 4e090a3 commit b811ebe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ let strictConcurrencySettings: [SwiftSetting] = [
.enableUpcomingFeature("InferSendableFromCaptures"),
]

// Add these Swift settings to targets that need to be validated
// for strict concurrency.
let diagnosticSettings: [SwiftSetting] = [
.unsafeFlags(["-require-explicit-sendable", "-warnings-as-errors"]),
]

// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and
// Foundation will be linked. This is, however, strictly better than unconditionally adding the
// resource.
Expand Down Expand Up @@ -71,7 +77,8 @@ let package = Package(
]
),
.target(
name: "_NIODataStructures"
name: "_NIODataStructures",
swiftSettings: strictConcurrencySettings
),
.target(
name: "_NIOBase64"
Expand Down
2 changes: 2 additions & 0 deletions Sources/_NIODataStructures/_TinyArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ extension _TinyArray: RandomAccessCollection {
}
}

extension _TinyArray.Iterator: Sendable where Element: Sendable {}

extension _TinyArray {
@inlinable
public init(_ elements: some Sequence<Element>) {
Expand Down

0 comments on commit b811ebe

Please sign in to comment.