Skip to content

Commit efb08f9

Browse files
authored
Add explicit sendability annotations (#831)
Motivation: As part of adopting strict concurrency all public types should be explicit about whether they are sendable or not. Modifications: - Add explicit sendability annotations to a number of types Result: Sendability is explicit
1 parent a3d00a6 commit efb08f9

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

Sources/AsyncHTTPClient/AsyncAwait/AnyAsyncSequence.swift

+3
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ struct AnyAsyncSequence<Element>: Sendable, AsyncSequence {
4646
.init(nextCallback: self.makeAsyncIteratorCallback())
4747
}
4848
}
49+
50+
@available(*, unavailable)
51+
extension AnyAsyncSequence.AsyncIterator: Sendable {}

Sources/AsyncHTTPClient/AsyncAwait/HTTPClientResponse.swift

+6
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,9 @@ extension HTTPClientResponse.Body {
259259
.stream(CollectionOfOne(byteBuffer).async)
260260
}
261261
}
262+
263+
@available(*, unavailable)
264+
extension HTTPClientResponse.Body.AsyncIterator: Sendable {}
265+
266+
@available(*, unavailable)
267+
extension HTTPClientResponse.Body.Storage.AsyncIterator: Sendable {}

Sources/AsyncHTTPClient/AsyncAwait/Transaction+StateMachine.swift

+3
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,6 @@ extension Transaction {
552552
}
553553
}
554554
}
555+
556+
@available(*, unavailable)
557+
extension Transaction.StateMachine: Sendable {}

Sources/AsyncHTTPClient/Base64.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension String {
2929

3030
// swift-format-ignore: DontRepeatTypeInStaticProperties
3131
@usableFromInline
32-
internal struct Base64 {
32+
internal struct Base64: Sendable {
3333

3434
@inlinable
3535
static func encode<Buffer: Collection>(

Sources/AsyncHTTPClient/Utils.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import NIOCore
1818
///
1919
/// ``HTTPClientCopyingDelegate`` discards most parts of a HTTP response, but streams the body
2020
/// to the `chunkHandler` provided on ``init(chunkHandler:)``. This is mostly useful for testing.
21-
public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate {
21+
public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate, Sendable {
2222
public typealias Response = Void
2323

24-
let chunkHandler: (ByteBuffer) -> EventLoopFuture<Void>
24+
let chunkHandler: @Sendable (ByteBuffer) -> EventLoopFuture<Void>
2525

2626
@preconcurrency
2727
public init(chunkHandler: @Sendable @escaping (ByteBuffer) -> EventLoopFuture<Void>) {

0 commit comments

Comments
 (0)