@@ -88,7 +88,7 @@ open class URLSessionTask : NSObject, NSCopying {
88
88
originalRequest = nil
89
89
body = . none
90
90
workQueue = DispatchQueue ( label: " URLSessionTask.notused.0 " )
91
- taskAttributesIsolation = DispatchQueue ( label: " URLSessionTask.notused.1 " )
91
+ taskAttributesIsolation = DispatchQueue ( label: " URLSessionTask.notused.1 " , attributes : DispatchQueue . Attributes . concurrent )
92
92
let fileName = NSTemporaryDirectory ( ) + NSUUID( ) . uuidString + " .tmp "
93
93
_ = FileManager . default. createFile ( atPath: fileName, contents: nil )
94
94
self . tempFileURL = URL ( fileURLWithPath: fileName)
@@ -145,7 +145,7 @@ open class URLSessionTask : NSObject, NSCopying {
145
145
return r
146
146
}
147
147
//TODO: dispatch_barrier_async
148
- set { taskAttributesIsolation. async { self . _currentRequest = newValue } }
148
+ set { taskAttributesIsolation. async ( flags : . barrier ) { self . _currentRequest = newValue } }
149
149
}
150
150
fileprivate var _currentRequest : URLRequest ? = nil
151
151
/*@NSCopying*/ open fileprivate( set) var response : URLResponse ? {
@@ -154,7 +154,7 @@ open class URLSessionTask : NSObject, NSCopying {
154
154
taskAttributesIsolation. sync { r = self . _response }
155
155
return r
156
156
}
157
- set { taskAttributesIsolation. async { self . _response = newValue } }
157
+ set { taskAttributesIsolation. async ( flags : . barrier ) { self . _response = newValue } }
158
158
}
159
159
fileprivate var _response : URLResponse ? = nil
160
160
@@ -170,7 +170,7 @@ open class URLSessionTask : NSObject, NSCopying {
170
170
taskAttributesIsolation. sync { r = self . _countOfBytesReceived }
171
171
return r
172
172
}
173
- set { taskAttributesIsolation. async { self . _countOfBytesReceived = newValue } }
173
+ set { taskAttributesIsolation. async ( flags : . barrier ) { self . _countOfBytesReceived = newValue } }
174
174
}
175
175
fileprivate var _countOfBytesReceived : Int64 = 0
176
176
@@ -181,7 +181,7 @@ open class URLSessionTask : NSObject, NSCopying {
181
181
taskAttributesIsolation. sync { r = self . _countOfBytesSent }
182
182
return r
183
183
}
184
- set { taskAttributesIsolation. async { self . _countOfBytesSent = newValue } }
184
+ set { taskAttributesIsolation. async ( flags : . barrier ) { self . _countOfBytesSent = newValue } }
185
185
}
186
186
187
187
fileprivate var _countOfBytesSent : Int64 = 0
@@ -213,7 +213,7 @@ open class URLSessionTask : NSObject, NSCopying {
213
213
taskAttributesIsolation. sync { r = self . _state }
214
214
return r
215
215
}
216
- set { taskAttributesIsolation. async { self . _state = newValue } }
216
+ set { taskAttributesIsolation. async ( flags : . barrier ) { self . _state = newValue } }
217
217
}
218
218
fileprivate var _state : URLSessionTask . State = . suspended
219
219
@@ -298,7 +298,7 @@ open class URLSessionTask : NSObject, NSCopying {
298
298
return r
299
299
}
300
300
set {
301
- taskAttributesIsolation. async { self . _priority = newValue }
301
+ taskAttributesIsolation. async ( flags : . barrier ) { self . _priority = newValue }
302
302
}
303
303
}
304
304
fileprivate var _priority : Float = URLSessionTaskPriorityDefault
@@ -791,7 +791,7 @@ extension URLSessionTask: _EasyHandleDelegate {
791
791
// to the delegate. But in case of redirects etc. we might send another
792
792
// request.
793
793
guard case . transferInProgress( let ts) = internalState else { fatalError ( " Transfer completed, but it wasn't in progress. " ) }
794
- guard let request = currentRequest else { fatalError ( " Transfer completed, but there's no currect request. " ) }
794
+ guard let request = currentRequest else { fatalError ( " Transfer completed, but there's no current request. " ) }
795
795
guard errorCode == nil else {
796
796
internalState = . transferFailed
797
797
failWith ( errorCode: errorCode!, request: request)
0 commit comments