Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerd committed Apr 13, 2022
1 parent bb34ac6 commit 297788b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 4 additions & 3 deletions Sources/AWSLambdaRuntimeCore/LambdaHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import NIOCore
/// level protocols ``EventLoopLambdaHandler`` and
/// ``ByteBufferLambdaHandler``.
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
public protocol LambdaHandler: EventLoopLambdaHandler where Event: _AWSLambdaSendable {
public protocol LambdaHandler: EventLoopLambdaHandler {
/// The Lambda initialization method
/// Use this method to initialize resources that will be used in every request.
///
Expand Down Expand Up @@ -69,15 +69,16 @@ extension LambdaHandler {
}

/// unchecked sendable wrapper for the handler
/// this is safe since lambda runtime is designed to calls the handler serially
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
fileprivate struct UncheckedSendableHandler<Underlying: LambdaHandler>: @unchecked Sendable {
fileprivate struct UncheckedSendableHandler<Underlying: LambdaHandler, Event, Output>: @unchecked Sendable where Event == Underlying.Event, Output == Underlying.Output {
let underlying: Underlying

init(underlying: Underlying) {
self.underlying = underlying
}

func handle(_ event: Underlying.Event, context: LambdaContext) async throws -> Underlying.Output {
func handle(_ event: Event, context: LambdaContext) async throws -> Output {
try await self.underlying.handle(event, context: context)
}
}
Expand Down
5 changes: 0 additions & 5 deletions Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,3 @@ public final class LambdaRuntime<Handler: ByteBufferLambdaHandler> {
}
}
}

// TODO: ideally this would not be @unchecked Sendable, but Sendable checks do not understand locks
#if compiler(>=5.5) && canImport(_Concurrency)
extension LambdaRuntime: @unchecked Sendable {}
#endif
3 changes: 2 additions & 1 deletion Sources/AWSLambdaRuntimeCore/Terminator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ extension LambdaTerminator {
}
}

// TODO: ideally this would not be @unchecked Sendable, but Sendable checks do not understand locks
// Ideally this would not be @unchecked Sendable, but Sendable checks do not understand locks
// We can transition this to an actor once we drop support for older Swift versions
#if compiler(>=5.5) && canImport(_Concurrency)
extension LambdaTerminator: @unchecked Sendable {}
extension LambdaTerminator.Storage: @unchecked Sendable {}
Expand Down

0 comments on commit 297788b

Please sign in to comment.