Skip to content

[SR-11333] OperationQueue work not properly with Operation dependency #4484

@swift-ci

Description

@swift-ci
Previous ID SR-11333
Radar None
Original Reporter DannyLiu (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode: Version 10.3 (10G8)

macos: 10.14.6 (18G87)

swift-corelibs-foundation: tag swift-5.0-RELEASE ~ swift-5.0.2-RELEASE

swift-5.1 has a similar problem.

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 8ceaa0baef5b0f9f960fe3fc42ba6b8b

Issue Description:

Create a test like that:

    func test_OperationDependencies() {
        let queue = OperationQueue()
        queue.maxConcurrentOperationCount = 1
        let op1 = BlockOperation {
            print("execute op1")
        }
        let op2 = BlockOperation {
            print("execute op2")
        }
        op1.addDependency(op2)
        queue.addOperation(op1)
        queue.addOperation(op2)
        queue.waitUntilAllOperationsAreFinished()
    }

The process will hangout when running the test case.

However, this test works fine with Foundation on Darwin. I read the source of Operation.swift, there should be a bug for the implementation of dependency logic.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions