Skip to content

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Apr 28, 2025

Description: This changes the isIsolatingCurrentContext function to return Bool? and removes all the witness table trickery we did previously to detect if it was implemented or not. This comes at a cost of trying to invoke it always, before checkIsolated, but it makes for an simpler implementation and more checkable even by third party Swift code which may want to ask this question.

Along with the withSerialExecutor function, this now enables us to check the isolation at runtime when we have an any Actor e.g. from #isolation.

Updates SE-0471 according to
https://forums.swift.org/t/se-0471-improved-custom-serialexecutor-isolation-checking-for-concurrency-runtime/78834/ review discussions

Scope/Impact: Adjusts protocol requirement which didn't ship nor was adopted yet in other APIs.
Risk: Low, this API wasn't adopted in many places yet.
Testing: CI testing
Reviewed by: @DougGregor

Original PR:

Radar:

@ktoso ktoso requested a review from a team as a code owner April 28, 2025 10:05
@ktoso ktoso changed the title [Concurrency] Change isIsolatingCurrent... to return Bool? [6.2][Concurrency] Change isIsolatingCurrent... to return Bool? Apr 28, 2025
MaxDesiatov and others added 2 commits April 28, 2025 19:16
….cpp`"" (swiftlang#80692)

* Revert "Revert "Concurrency: Move code between `Executor{Bridge,Impl}.cpp`""

* Update CMakeLists.txt
This changes the isIsolatingCurrentContext function to return `Bool?`
and removes all the witness table trickery we did previously to detect
if it was implemented or not. This comes at a cost of trying to invoke
it always, before `checkIsolated`, but it makes for an simpler
implementation and more checkable even by third party Swift code which
may want to ask this question.

Along with the `withSerialExecutor` function, this now enables us to
check the isolation at runtime when we have an `any Actor` e.g. from
`#isolation`.

Updates SE-0471 according to
https://forums.swift.org/t/se-0471-improved-custom-serialexecutor-isolation-checking-for-concurrency-runtime/78834/
review discussions
@ktoso ktoso force-pushed the pick-22b20e731eaa70746d3c21bf8c44836aa49dfabb branch from 1bc765a to c6e38ce Compare April 28, 2025 10:18
@ktoso ktoso requested review from DougGregor and al45tair April 28, 2025 10:18
@ktoso
Copy link
Contributor Author

ktoso commented Apr 28, 2025

@swift-ci please test

@ktoso ktoso force-pushed the pick-22b20e731eaa70746d3c21bf8c44836aa49dfabb branch from c6e38ce to a63356e Compare April 28, 2025 11:26
@ktoso
Copy link
Contributor Author

ktoso commented Apr 28, 2025

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented Apr 29, 2025

@swift-ci please test

1 similar comment
@ktoso
Copy link
Contributor Author

ktoso commented May 1, 2025

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented May 1, 2025

Meanwhile we decided we won't be doing the withSerialExecutor so I've hidden it right away even though we use it in a test, so folks don't accidentally start using it.

This should be good to land though and is "complete" if we want the SE suggested -> Bool? version.

cc @DougGregor

@ktoso
Copy link
Contributor Author

ktoso commented May 1, 2025

@swift-ci please test

@ktoso ktoso merged commit f6a864a into swiftlang:release/6.2 May 1, 2025
5 checks passed
@ktoso ktoso deleted the pick-22b20e731eaa70746d3c21bf8c44836aa49dfabb branch May 7, 2025 01:24
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