Skip to content

Add explicit sendability annotations #831

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

Merged
merged 1 commit into from
Apr 28, 2025
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
3 changes: 3 additions & 0 deletions Sources/AsyncHTTPClient/AsyncAwait/AnyAsyncSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ struct AnyAsyncSequence<Element>: Sendable, AsyncSequence {
.init(nextCallback: self.makeAsyncIteratorCallback())
}
}

@available(*, unavailable)
extension AnyAsyncSequence.AsyncIterator: Sendable {}
6 changes: 6 additions & 0 deletions Sources/AsyncHTTPClient/AsyncAwait/HTTPClientResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,9 @@ extension HTTPClientResponse.Body {
.stream(CollectionOfOne(byteBuffer).async)
}
}

@available(*, unavailable)
extension HTTPClientResponse.Body.AsyncIterator: Sendable {}

@available(*, unavailable)
extension HTTPClientResponse.Body.Storage.AsyncIterator: Sendable {}
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,6 @@ extension Transaction {
}
}
}

@available(*, unavailable)
extension Transaction.StateMachine: Sendable {}
2 changes: 1 addition & 1 deletion Sources/AsyncHTTPClient/Base64.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension String {

// swift-format-ignore: DontRepeatTypeInStaticProperties
@usableFromInline
internal struct Base64 {
internal struct Base64: Sendable {

@inlinable
static func encode<Buffer: Collection>(
Expand Down
4 changes: 2 additions & 2 deletions Sources/AsyncHTTPClient/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import NIOCore
///
/// ``HTTPClientCopyingDelegate`` discards most parts of a HTTP response, but streams the body
/// to the `chunkHandler` provided on ``init(chunkHandler:)``. This is mostly useful for testing.
public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate {
public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate, Sendable {
public typealias Response = Void

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

@preconcurrency
public init(chunkHandler: @Sendable @escaping (ByteBuffer) -> EventLoopFuture<Void>) {
Expand Down
Loading