Skip to content
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

[SR-11854] OperationQueue not asynchronous #612

Closed
swift-ci opened this issue Nov 25, 2019 · 2 comments
Closed

[SR-11854] OperationQueue not asynchronous #612

swift-ci opened this issue Nov 25, 2019 · 2 comments

Comments

@swift-ci
Copy link

Previous ID SR-11854
Radar rdar://problem/57549294
Original Reporter ZakMcK (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift Runtime

Swift version 5.1 (swift-5.1.2-RELEASE)
Target: x86_64-unknown-linux-gnu

OS

Additional Detail from JIRA
Votes 0
Component/s Foundation, libdispatch
Labels Bug
Assignee @lxbndr
Priority Medium

md5: 7ac99bf05c7d6c768f6910f21d555ebb

Issue Description:

I have a problem with the OperationQueue in the swift-5.1.2-RELEASE version. The whole OperationQueue seems to work synchronously with one single thread instead of using all available cores.

This worked with swift 5.0. Following example

let testQueue = OperationQueue()
testQueue.name = "TestAsync"
testQueue.maxConcurrentOperationCount = 4

for _ in 0...10 {
    testQueue.addOperation { 
        print("added \(Thread.current) on \(OperationQueue.current?.underlyingQueue?.label ?? "None")")
        //Thread.sleep(forTimeInterval: 1)
    }
    //print("OP COUNT: \(testQueue.operationCount)")
}

testQueue.waitUntilAllOperationsAreFinished()

yields this output

Hello, world!
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
OP COUNT: 1
done pushing operations
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None
added <Thread: 0x00007f8e14000c80> on None

I would assume that different threads should be incorporated (maxConcurrentOperationCount is set to 4).

@beccadax
Copy link

beccadax commented Dec 2, 2019

@swift-ci create

@lxbndr
Copy link

lxbndr commented Jan 18, 2021

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants