1212//
1313//===----------------------------------------------------------------------===//
1414
15+ import Synchronization
1516import Logging
16- import NIOConcurrencyHelpers
1717import NIOCore
1818
1919#if canImport(FoundationEssentials)
@@ -26,8 +26,7 @@ import Foundation
2626// We don't want to use `NIOLockedValueBox` here anyway. We would love to use Mutex here, but this
2727// sadly crashes the compiler today.
2828public final class LambdaRuntime < Handler> : @unchecked Sendable where Handler: StreamingLambdaHandler {
29- // TODO: We want to change this to Mutex as soon as this doesn't crash the Swift compiler on Linux anymore
30- let handlerMutex : NIOLockedValueBox < Handler ? >
29+ let handlerMutex : Mutex < Handler ? >
3130 let logger : Logger
3231 let eventLoop : EventLoop
3332
@@ -36,7 +35,7 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
3635 eventLoop: EventLoop = Lambda . defaultEventLoop,
3736 logger: Logger = Logger ( label: " LambdaRuntime " )
3837 ) {
39- self . handlerMutex = NIOLockedValueBox ( handler)
38+ self . handlerMutex = Mutex ( handler)
4039 self . eventLoop = eventLoop
4140
4241 // by setting the log level here, we understand it can not be changed dynamically at runtime
@@ -49,7 +48,7 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
4948 }
5049
5150 public func run( ) async throws {
52- let handler = self . handlerMutex. withLockedValue { handler in
51+ let handler = self . handlerMutex. withLock { handler in
5352 let result = handler
5453 handler = nil
5554 return result
0 commit comments