File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -175,25 +175,35 @@ class AsyncOperation: Operation {
175
175
176
176
override internal( set) var isExecuting : Bool {
177
177
get {
178
- return _executing
178
+ lock. lock ( )
179
+ let wasExecuting = _executing
180
+ lock. unlock ( )
181
+ return wasExecuting
179
182
}
180
183
set {
181
- if _executing != newValue {
184
+ if isExecuting != newValue {
182
185
willChangeValue ( forKey: " isExecuting " )
186
+ lock. lock ( )
183
187
_executing = newValue
188
+ lock. unlock ( )
184
189
didChangeValue ( forKey: " isExecuting " )
185
190
}
186
191
}
187
192
}
188
193
189
194
override internal( set) var isFinished : Bool {
190
195
get {
191
- return _finished
196
+ lock. lock ( )
197
+ let wasFinished = _finished
198
+ lock. unlock ( )
199
+ return wasFinished
192
200
}
193
201
set {
194
- if _finished != newValue {
202
+ if isFinished != newValue {
195
203
willChangeValue ( forKey: " isFinished " )
204
+ lock. lock ( )
196
205
_finished = newValue
206
+ lock. unlock ( )
197
207
didChangeValue ( forKey: " isFinished " )
198
208
}
199
209
}
@@ -213,10 +223,8 @@ class AsyncOperation: Operation {
213
223
214
224
queue. async {
215
225
sleep ( 1 )
216
- self . lock. lock ( )
217
226
self . isExecuting = false
218
227
self . isFinished = true
219
- self . lock. unlock ( )
220
228
}
221
229
}
222
230
You can’t perform that action at this time.
0 commit comments