Skip to content

Commit fb02773

Browse files
lxbndrspevans
authored andcommitted
Fix OperationQueue counters
This fixes typos in code responsible for counting operations in queue. (cherry picked from commit d8c2cfa)
1 parent b98e5c1 commit fb02773

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/Foundation/Operation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ open class OperationQueue : NSObject, ProgressReporting {
10861086
defer { _unlock() }
10871087
var op = __firstOperation
10881088
var cnt = 0
1089-
if let operation = op?.takeUnretainedValue() {
1089+
while let operation = op?.takeUnretainedValue() {
10901090
if !(operation is _BarrierOperation) {
10911091
cnt += 1
10921092
}
@@ -1100,7 +1100,7 @@ open class OperationQueue : NSObject, ProgressReporting {
11001100
defer { _unlock() }
11011101
var operations = [Operation]()
11021102
var op = __firstOperation
1103-
if let operation = op?.takeUnretainedValue() {
1103+
while let operation = op?.takeUnretainedValue() {
11041104
if includingBarriers || !(operation is _BarrierOperation) {
11051105
operations.append(operation)
11061106
}

Tests/Foundation/Tests/TestOperationQueue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TestOperationQueue : XCTestCase {
1313
static var allTests: [(String, (TestOperationQueue) -> () throws -> Void)] {
1414
return [
1515
("test_OperationPriorities", test_OperationPriorities),
16-
/* ⚠️ */ ("test_OperationCount", testExpectedToFail(test_OperationCount, "OperationQueue can't count to more than 1")),
16+
("test_OperationCount", test_OperationCount),
1717
("test_AsyncOperation", test_AsyncOperation),
1818
("test_SyncOperationWithoutAQueue", test_SyncOperationWithoutAQueue),
1919
("test_isExecutingWorks", test_isExecutingWorks),

0 commit comments

Comments
 (0)