12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ import Synchronization
15
16
import Logging
16
- import NIOConcurrencyHelpers
17
17
import NIOCore
18
18
19
19
#if canImport(FoundationEssentials)
@@ -26,8 +26,7 @@ import Foundation
26
26
// We don't want to use `NIOLockedValueBox` here anyway. We would love to use Mutex here, but this
27
27
// sadly crashes the compiler today.
28
28
public 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 ? >
31
30
let logger : Logger
32
31
let eventLoop : EventLoop
33
32
@@ -36,7 +35,7 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
36
35
eventLoop: EventLoop = Lambda . defaultEventLoop,
37
36
logger: Logger = Logger ( label: " LambdaRuntime " )
38
37
) {
39
- self . handlerMutex = NIOLockedValueBox ( handler)
38
+ self . handlerMutex = Mutex ( handler)
40
39
self . eventLoop = eventLoop
41
40
42
41
// 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
49
48
}
50
49
51
50
public func run( ) async throws {
52
- let handler = self . handlerMutex. withLockedValue { handler in
51
+ let handler = self . handlerMutex. withLock { handler in
53
52
let result = handler
54
53
handler = nil
55
54
return result
0 commit comments