Overdrive icon indicating copy to clipboard operation
Overdrive copied to clipboard

maxConcurrentCount=1 only executes the first task in the queue

Open xinsight opened this issue 7 years ago • 2 comments

Overdrive: 0.3 Package manager (SPM, Carthage, CocoaPods, Manual): n/a Xcode: 8.3.2 (macOS 10.12.5) Platform: iOS

When TaskQueue.maximumConcurrentTaskCount = 1`, only one task is executed. (The 2nd task is not executed.)

Here is a test case that indicates the issue.

    func testTwoTaskShouldBothCompleteWhenMaxConcurrentTaskCountIsOne() {

        queue.maxConcurrentTaskCount = 1

        let expectation1 = self.expectation(description: "a")
        let expectation2 = self.expectation(description: "b")

        let task = anyTask(withResult: .value(1))
        task.onValue { _ in
            expectation1.fulfill()
        }
        let task2 = anyTask(withResult: .value(1))
        task2.onValue { _ in
            expectation2.fulfill()
        }
        queue.add(task: task)
        queue.add(task: task2)

        waitForExpectations(timeout: 5)

    }

The test fails as the "b" expectation is unfulfilled. Any ideas what could be wrong?

xinsight avatar Aug 30 '17 15:08 xinsight

Hi @xinsight, I'm looking into it.

saidsikira avatar Aug 31 '17 08:08 saidsikira

Hi @arikis, what is the current state of this issue? Any insights? I'm experimenting with the current swift4 branch (bd7550b27f0023ba0e612e0e56b9e0ecd06f7705) and can see a similar behaviour (Xcode 9, iOS 11).

zykloman avatar Sep 22 '17 14:09 zykloman