Skip to content

fix NSOperationQueue to retain operation in 'all' queue once it is dispatched #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions Foundation/NSOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,24 +258,22 @@ internal struct _OperationList {
}

mutating func dequeue() -> NSOperation? {
var result : NSOperation?
if veryHigh.count > 0 {
result = veryHigh.remove(at: 0)
} else if high.count > 0 {
result = high.remove(at: 0)
} else if normal.count > 0 {
result = normal.remove(at: 0)
} else if low.count > 0 {
result = low.remove(at: 0)
} else if veryLow.count > 0 {
result = veryLow.remove(at: 0)
return veryHigh.remove(at: 0)
}

if let idx = all.index(of: result!) {
all.remove(at: idx)
if high.count > 0 {
return high.remove(at: 0)
}

return result
if normal.count > 0 {
return normal.remove(at: 0)
}
if low.count > 0 {
return low.remove(at: 0)
}
if veryLow.count > 0 {
return veryLow.remove(at: 0)
}
return nil
}

var count: Int {
Expand Down