-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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-14841] Concurrency: Resuming a stored continuation from an actor does not work #57188
Comments
@swift-ci create |
This is working for me with the main and 5.5 branches. However, I note that this is missing the code to run doIt() anywhere. If you only had: doIt() then the program will likely exit before the async task completes. Put a silly Thread.sleep(forTimeInterval: 1) after it and things should be fine. Or, better yet, use `@main` with an async main function |
@DougGregor Thanks for taking a look at it. Obviously the example file was not self-contained, but a stripped down part of a larger program, my bad. It's still not working for me with the latest 5.5 snapshot. Please use the example project @ https://github.com/mickeyl/swift-bugs and run it in iOS 15 simulator. With the `StreamCommandQueue being an `actor`, the output is: awaiting... continuation: CheckedContinuation<String, Error>(canary: Swift.CheckedContinuationCanary)
<triggering continuation resume> CheckedContinuation<String, Error>(canary: Swift.CheckedContinuationCanary)
</triggering continuation resume>
The continuation hangs. With the `StreamCommandQueue` being a `class`, the output is: awaiting... continuation: CheckedContinuation<String, Error>(canary: Swift.CheckedContinuationCanary)
<triggering continuation resume> CheckedContinuation<String, Error>(canary: Swift.CheckedContinuationCanary)
</triggering continuation resume>
came back after awaiting
The continuation continues (sic!). |
No changes in Xcode 12b3. |
No changes in Xcode 12b4. It would be nice if this issue would either be confirmed or If I'm "holding it wrong", please tell me how actors and continuations are supposed to be used. |
Hi, this is confirmed in Xcode 13 beta 4 release notes (https://developer.apple.com/documentation/xcode-release-notes/xcode-13-beta-release-notes) under Known Issues Resuming a stored continuation in a Task.init(priority:operation:) context (previously async(priority:operation:)). (SR-14802, SR-14841, SR-14875) with a potential workaround of using a detached task instead of Task.init/async { }. |
This seems to work now with Xcode13b5
on macOS 12 beta. |
Environment
Xcode 13 beta 4, iOS 15 simulator on macOS 11.4 on Mac6,1 (2013).
Xcode 13 beta 4, iOS 15 simulator on macOS 12b4 on M1-Mac (2020).
Xcode 13 beta 4, macOS/Catalyst on macOS 12b4 on M1-Mac (2020).
Additional Detail from JIRA
md5: 42907e573028b4f88cb3e358fca70d55
relates to:
Issue Description:
Please consider the following example program which seems to expose an incompatibility when storing a continuation somewhere and resuming it later from within an actor.
The text was updated successfully, but these errors were encountered: