-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[TaskExecutors] Task initializer and withTaskExecutor parameter changes #70783
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
[TaskExecutors] Task initializer and withTaskExecutor parameter changes #70783
Conversation
|
@swift-ci please smoke test |
|
Related proposal text swiftlang/swift-evolution#2271 |
447b90e to
8db39ed
Compare
|
@swift-ci please smoke test |
8db39ed to
025b21a
Compare
025b21a to
7152811
Compare
| } | ||
| // TODO: introduce a set {} once we are ready to allow customizing the | ||
| // default global executor. This should be done the same for main actor | ||
| } |
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.
so here's the new global @DougGregor
| @available(SwiftStdlib 9999, *) | ||
| @_alwaysEmitIntoClient | ||
| @inlinable | ||
| public func runSynchronously(isolated serialExecutor: 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.
|
@swift-ci please smoke test |
1 similar comment
|
@swift-ci please smoke test |
Follow up to #68793 bases on SE input.
This API revision allows passing
(any TaskExecutor)?to all the new APIs. Passingnilas a preference means "no preference" which means that the parent's executor preference is used for structured concurrency, and the means no change in unstructured tasks but is a simple way to pass around an optional preference through APIs if necessary.We also introduce a new global
nonisolated(unsafe) var globalConcurrentExecutor: any TaskExecutor { get }.Previous revision
Previous API shape required the
nilvalue to be used as "no preference".During review we came up with an idea that if we make the "default global concurrent executor" an accessible value, we can express it as:
withTaskExecutor(.default)and therefore avoid thenilwhich can be a bit cryptic.It does mean we have to add
public final class DefaultConcurrentExecutorwhich delegates to the "default global executor" but the APIs can then use it.The
Task(on: .default)reads a bit weird now though. Perhaps we should change it toTask(executorPreference: .default), and do the same to theaddTask(executorPreference: ...)and friends now that the.defaultcan be passed?