File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -76,9 +76,7 @@ class TestNSOperationQueue : XCTestCase {
76
76
operation. start ( )
77
77
78
78
while !operation. isFinished {
79
- // wait until the operation finishes
80
- XCTAssertTrue ( operation. isExecuting)
81
- XCTAssertFalse ( operation. isFinished)
79
+ // do nothing
82
80
}
83
81
84
82
XCTAssertFalse ( operation. isExecuting)
@@ -89,6 +87,7 @@ class TestNSOperationQueue : XCTestCase {
89
87
class AsyncOperation : Operation {
90
88
91
89
private let queue = DispatchQueue ( label: " async.operation.queue " )
90
+ private let lock = NSLock ( )
92
91
93
92
private var _executing = false
94
93
private var _finished = false
@@ -133,8 +132,10 @@ class AsyncOperation: Operation {
133
132
134
133
queue. async {
135
134
sleep ( 1 )
135
+ self . lock. lock ( )
136
136
self . isExecuting = false
137
137
self . isFinished = true
138
+ self . lock. unlock ( )
138
139
}
139
140
}
140
141
You can’t perform that action at this time.
0 commit comments