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 missing 'Sendable' conformance #1404

Merged
merged 1 commit into from
May 12, 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
4 changes: 2 additions & 2 deletions Sources/Examples/Echo/Model/echo.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ extension Echo_EchoAsyncClientProtocol {
public func collect<RequestStream>(
_ requests: RequestStream,
callOptions: CallOptions? = nil
) async throws -> Echo_EchoResponse where RequestStream: AsyncSequence, RequestStream.Element == Echo_EchoRequest {
) async throws -> Echo_EchoResponse where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Echo_EchoRequest {
return try await self.performAsyncClientStreamingCall(
path: Echo_EchoClientMetadata.Methods.collect.path,
requests: requests,
Expand All @@ -340,7 +340,7 @@ extension Echo_EchoAsyncClientProtocol {
public func update<RequestStream>(
_ requests: RequestStream,
callOptions: CallOptions? = nil
) -> GRPCAsyncResponseStream<Echo_EchoResponse> where RequestStream: AsyncSequence, RequestStream.Element == Echo_EchoRequest {
) -> GRPCAsyncResponseStream<Echo_EchoResponse> where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Echo_EchoRequest {
return self.performAsyncBidirectionalStreamingCall(
path: Echo_EchoClientMetadata.Methods.update.path,
requests: requests,
Expand Down
4 changes: 2 additions & 2 deletions Sources/Examples/RouteGuide/Model/route_guide.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ extension Routeguide_RouteGuideAsyncClientProtocol {
public func recordRoute<RequestStream>(
_ requests: RequestStream,
callOptions: CallOptions? = nil
) async throws -> Routeguide_RouteSummary where RequestStream: AsyncSequence, RequestStream.Element == Routeguide_Point {
) async throws -> Routeguide_RouteSummary where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Routeguide_Point {
return try await self.performAsyncClientStreamingCall(
path: Routeguide_RouteGuideClientMetadata.Methods.recordRoute.path,
requests: requests,
Expand All @@ -359,7 +359,7 @@ extension Routeguide_RouteGuideAsyncClientProtocol {
public func routeChat<RequestStream>(
_ requests: RequestStream,
callOptions: CallOptions? = nil
) -> GRPCAsyncResponseStream<Routeguide_RouteNote> where RequestStream: AsyncSequence, RequestStream.Element == Routeguide_RouteNote {
) -> GRPCAsyncResponseStream<Routeguide_RouteNote> where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Routeguide_RouteNote {
return self.performAsyncBidirectionalStreamingCall(
path: Routeguide_RouteGuideClientMetadata.Methods.routeChat.path,
requests: requests,
Expand Down
2 changes: 1 addition & 1 deletion Sources/GRPC/AsyncAwaitSupport/AsyncWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal final actor AsyncWriter<Delegate: AsyncWriterDelegate>: Sendable {
typealias PendingEnd = _Pending<End>

@usableFromInline
internal enum _CompletionState {
internal enum _CompletionState: Sendable {
/// Finish hasn't been called yet. May move to `pending` or `completed`.
case incomplete
/// Finish has been called but the writer is paused. May move to `completed`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import NIOHPACK

/// Async-await variant of BidirectionalStreamingCall.
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public struct GRPCAsyncBidirectionalStreamingCall<Request: Sendable, Response: Sendable> {
public struct GRPCAsyncBidirectionalStreamingCall<Request: Sendable, Response: Sendable>: Sendable {
private let call: Call<Request, Response>
private let responseParts: StreamingResponseParts<Response>
private let responseSource: PassthroughMessageSource<Response, Error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import NIOHPACK

/// Async-await variant of `ClientStreamingCall`.
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public struct GRPCAsyncClientStreamingCall<Request: Sendable, Response: Sendable> {
public struct GRPCAsyncClientStreamingCall<Request: Sendable, Response: Sendable>: Sendable {
private let call: Call<Request, Response>
private let responseParts: UnaryResponseParts<Response>

Expand Down
5 changes: 5 additions & 0 deletions Sources/GRPC/AsyncAwaitSupport/GRPCAsyncRequestStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public struct GRPCAsyncRequestStream<Element: Sendable>: AsyncSequence {
}
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension GRPCAsyncRequestStream: Sendable where Element: Sendable {}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension GRPCAsyncRequestStream.Iterator: Sendable where Element: Sendable {}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/// try await stream.finish()
/// ```
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public struct GRPCAsyncRequestStreamWriter<Request: Sendable> {
public struct GRPCAsyncRequestStreamWriter<Request: Sendable>: Sendable {
@usableFromInline
internal let asyncWriter: AsyncWriter<Delegate<Request>>

Expand Down
5 changes: 5 additions & 0 deletions Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ public struct GRPCAsyncResponseStream<Element>: AsyncSequence {
}
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension GRPCAsyncResponseStream: Sendable where Element: Sendable {}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension GRPCAsyncResponseStream.Iterator: Sendable where Element: Sendable {}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/// Writer for server-streaming RPC handlers to provide responses.
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public struct GRPCAsyncResponseStreamWriter<Response: Sendable> {
public struct GRPCAsyncResponseStreamWriter<Response: Sendable>: Sendable {
@usableFromInline
internal typealias Element = (Response, Compression)

Expand Down
2 changes: 1 addition & 1 deletion Sources/GRPC/AsyncAwaitSupport/GRPCAsyncUnaryCall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import NIOHPACK
/// Note: while this object is a `struct`, its implementation delegates to `Call`. It therefore
/// has reference semantics.
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public struct GRPCAsyncUnaryCall<Request: Sendable, Response: Sendable> {
public struct GRPCAsyncUnaryCall<Request: Sendable, Response: Sendable>: Sendable {
private let call: Call<Request, Response>
private let responseParts: UnaryResponseParts<Response>

Expand Down
Loading