File tree 1 file changed +5
-9
lines changed
Sources/AWSLambdaRuntimeCore
1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 14
14
15
15
import Foundation
16
16
import Logging
17
- import NIOConcurrencyHelpers
18
17
import NIOCore
18
+ import Synchronization
19
19
20
- // We need `@unchecked` Sendable here, as `NIOLockedValueBox` does not understand `sending` today.
21
- // We don't want to use `NIOLockedValueBox` here anyway. We would love to use Mutex here, but this
22
- // sadly crashes the compiler today.
23
- public final class LambdaRuntime < Handler> : @unchecked Sendable where Handler: StreamingLambdaHandler {
24
- // TODO: We want to change this to Mutex as soon as this doesn't crash the Swift compiler on Linux anymore
25
- let handlerMutex : NIOLockedValueBox < Handler ? >
20
+ public final class LambdaRuntime < Handler> : Sendable where Handler: StreamingLambdaHandler {
21
+ let handlerMutex : Mutex < Handler ? >
26
22
let logger : Logger
27
23
let eventLoop : EventLoop
28
24
@@ -31,7 +27,7 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
31
27
eventLoop: EventLoop = Lambda . defaultEventLoop,
32
28
logger: Logger = Logger ( label: " LambdaRuntime " )
33
29
) {
34
- self . handlerMutex = NIOLockedValueBox ( handler)
30
+ self . handlerMutex = Mutex ( handler)
35
31
self . eventLoop = eventLoop
36
32
self . logger = logger
37
33
}
@@ -45,7 +41,7 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
45
41
let ip = String ( ipAndPort [ 0 ] )
46
42
guard let port = Int ( ipAndPort [ 1 ] ) else { throw LambdaRuntimeError ( code: . invalidPort) }
47
43
48
- let handler = self . handlerMutex. withLockedValue { handler in
44
+ let handler = self . handlerMutex. withLock { handler in
49
45
let result = handler
50
46
handler = nil
51
47
return result
You can’t perform that action at this time.
0 commit comments