-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] Distributed actor's unownedExecutor should be optional #64499
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
[Concurrency] Distributed actor's unownedExecutor should be optional #64499
Conversation
@@ -255,6 +260,29 @@ public protocol DistributedActor: AnyActor, Identifiable, Hashable | |||
/// be introduced when not strictly required. Visible side effects | |||
/// are therefore strongly discouraged within this property. | |||
@available(SwiftStdlib 5.9, *) | |||
nonisolated var localUnownedExecutor: UnownedSerialExecutor? { get } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core of this PR, everything else is just in order to enable it.
@@ -11,7 +11,7 @@ | |||
//===----------------------------------------------------------------------===// | |||
|
|||
import Swift | |||
import _Concurrency | |||
@_spi(ConcurrencyExecutors) import _Concurrency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: cant make use of it after all because we need the executor initializer from an inlinable function.
b668f95
to
dfc373a
Compare
@swift-ci please smoke test |
This should work fine, though I'm working to get rid of the |
This weird failure again:
|
@swift-ci please clean smoke test macOS |
} | ||
|
||
@available(SwiftStdlib 5.9, *) | ||
public var _unwrapLocalUnownedExecutor: UnownedSerialExecutor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could make this a free function... perhaps easier than a full impl in SIL
@swift-ci please clean smoke test |
@@ -255,7 +260,7 @@ public protocol DistributedActor: AnyActor, Identifiable, Hashable | |||
/// be introduced when not strictly required. Visible side effects | |||
/// are therefore strongly discouraged within this property. | |||
@available(SwiftStdlib 5.9, *) | |||
nonisolated var unownedExecutor: UnownedSerialExecutor { get } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requirement has never shipped and cannot have been used by anyone yet, so making sure we have the right signature/requirement in the API/ABI for distributed actors by merging this now.
rdar://84054793 |
Implements the Swift Evolution feedback that it'd be better to implement this customization point properly with an
UnownedSerialExecutor?
which makes it more logical (and possible!) to implement correctly.@kavon's question https://forums.swift.org/t/se-0392-custom-actor-executors/63599/13
and my writeup: https://forums.swift.org/t/se-0392-custom-actor-executors/63599/16
Note that we never shipped distributed actors that had an
unownedExecutor
synthesized, so we don't have to be compatible with past implementations which had it configurable or synthesized -- it never was.The tests show various use-cases.
I took care to not break compatibility with previous implementations and we still detect "is default actor" using the old synthesized method. Though previously ALL distributed actors were default actors, even if you had provided the method yourself.
I believe this yields the right semantics but would really really ask for a review if I got the default implementation of
unownedExecutor
right -- the availability dance there I was unsure of.