Skip to content

Commit f81055e

Browse files
committed
Replace usage of NIOLockedValueBox with Mutex
1 parent 64b4179 commit f81055e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
import Synchronization
1516
import Logging
16-
import NIOConcurrencyHelpers
1717
import 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.
2828
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?>
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

Comments
 (0)