@@ -25,7 +25,7 @@ internal final class HTTPClient {
25
25
private let targetHost : String
26
26
27
27
private var state = State . disconnected
28
- private let executing = NIOAtomic . makeAtomic ( value : false )
28
+ private var executing = false
29
29
30
30
init ( eventLoop: EventLoop , configuration: Lambda . Configuration . RuntimeEngine ) {
31
31
self . eventLoop = eventLoop
@@ -50,7 +50,7 @@ internal final class HTTPClient {
50
50
51
51
/// cancels the current request if there is one
52
52
func cancel( ) {
53
- guard self . executing. exchange ( with : true ) else {
53
+ guard self . executing else {
54
54
// there is no request running. nothing to cancel
55
55
return
56
56
}
@@ -64,7 +64,10 @@ internal final class HTTPClient {
64
64
65
65
// TODO: cap reconnect attempt
66
66
private func execute( _ request: Request , validate: Bool = true ) -> EventLoopFuture < Response > {
67
- precondition ( !validate || self . executing. compareAndExchange ( expected: false , desired: true ) , " expecting single request at a time " )
67
+ if validate {
68
+ precondition ( self . executing == false )
69
+ self . executing = true
70
+ }
68
71
69
72
switch self . state {
70
73
case . disconnected:
@@ -80,7 +83,8 @@ internal final class HTTPClient {
80
83
81
84
let promise = channel. eventLoop. makePromise ( of: Response . self)
82
85
promise. futureResult. whenComplete { _ in
83
- precondition ( self . executing. compareAndExchange ( expected: true , desired: false ) , " invalid execution state " )
86
+ precondition ( self . executing == true )
87
+ self . executing = false
84
88
}
85
89
let wrapper = HTTPRequestWrapper ( request: request, promise: promise)
86
90
channel. writeAndFlush ( wrapper) . cascadeFailure ( to: promise)
0 commit comments