Skip to content

[Observation] Initial implementation of Observed for transactional tracked values over time (#79817) #82197

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

Merged

Conversation

phausler
Copy link
Contributor

@phausler phausler requested a review from a team as a code owner June 11, 2025 21:59
@stephentyrone
Copy link
Contributor

@swift-ci test

/// `Observations` conforms to `AsyncSequence`, providing a intutive and safe mechanism to track changes to
/// types that are marked as `@Observable` by using Swift Concurrency to indicate transactional boundaries
/// starting from the willSet of the first mutation to the next suspension point of the safe access.
@available(SwiftStdlib 9999, *)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(SwiftStdlib 6.2, *)

@phausler
Copy link
Contributor Author

@swift-ci please test

operation: @isolated(any) () async throws -> T,
onCancel handler: @Sendable () -> Void,
isolation: isolated (any Actor)? = #isolation
) async rethrows -> T {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i understand correctly the motivation for this (to deal with the isolation crossing issue i raised in an earlier iteration), it's not clear to me that the runtime hacks are necessary. can't you just pass the iterationIsolation through the relevant closures to ensure that the isolation of the operation and isolation parameters in the 'normal' cancellation handler function match? then there should be no dynamic suspension when awaiting the operation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to discuss this further, but let's do it in a separate issue thread (#82205).

@stephentyrone stephentyrone merged commit 90f6a8a into swiftlang:release/6.2 Jun 12, 2025
5 checks passed
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.

3 participants