Skip to content

[SE-0304] Align Task API implementation with the fourth revision of the proposal #38325

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

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Jul 9, 2021

Explanation: Task API changes to align the implementation with the fourth revision of the SE-0304 "Structured Concurrency. Most of the changes are superficial (e.g., renames, trivial additions) and have no ABI impact. The addition of cancellable Task.sleep(nanoseconds:) is a bit more involved because there's some subtle atomics manipulations going on, but the changes are limited to new API.
Scope: Affects programs that use Swift Concurrency. They'll get new "deprecation" warnings to help them move to the new APIs.
Radar/SR Issue: rdar://80339563
Risk: Low.
Testing: PR testing and CI on main.
Original PR: #38306

DougGregor added 10 commits July 8, 2021 17:31
Do this as a staged change to the ABI, introducing an underscored
`@usableFromInline` implementation to the ABI that we can rely on
later, and an `@_alwaysEmitIntoClient` version we can inline now.
The prior implementation of `Task.sleep()` effectively had two
different atomic words to capture the state, which could lead to cases
where cancelling before a sleep operation started would fail to
throw `CancellationError`. Reimplement the logic for the cancellable
sleep with a more traditional lock-free approach by
packing all of the state information into a single word, where we
always load, figure out what to do, then compare-and-swap.
@DougGregor DougGregor requested a review from a team as a code owner July 9, 2021 00:35
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please nominate

@DougGregor DougGregor merged commit e589ad0 into swiftlang:release/5.5 Jul 9, 2021
@DougGregor DougGregor deleted the structured-concurrency-review-4-5.5 branch July 9, 2021 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant