-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Clean up the TaskGroup ABI #36838
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
Clean up the TaskGroup ABI #36838
Conversation
- stop storing the parent task in the TaskGroup at the .swift level - make sure that swift_taskGroup_isCancelled is implied by the parent task being cancelled - make the TaskGroup structs frozen - make the withTaskGroup functions inlinable - remove swift_taskGroup_create - teach IRGen to allocate memory for the task group - don't deallocate the task group in swift_taskGroup_destroy To achieve the allocation change, introduce paired create/destroy builtins. Furthermore, remove the _swiftRetain and _swiftRelease functions and several calls to them. Replace them with uses of the appropriate builtins. I should probably change the builtins to return retained, since they're working with a managed type, but I'll do that in a separate commit.
@@ -591,7 +591,7 @@ public func withUnsafeCurrentTask<T>(body: (UnsafeCurrentTask?) throws -> T) ret | |||
// FIXME: This retain seems pretty wrong, however if we don't we WILL crash | |||
// with "destroying a task that never completed" in the task's destroy. | |||
// How do we solve this properly? | |||
_swiftRetain(_task) | |||
Builtin.retain(_task) |
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.
Oh i see, thank you.
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.
The remaining need for these is just that Builtin.currentAsyncTask()
is returning an unretained pointer. It probably simply shouldn't, but I wanted to leave that for a different PR.
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.
Yeah that probably makes sense 👍 All uses of the task will then fall into place properly I think
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.
Thanks a lot for the cleanup! It's actually very clear what's going on, thanks! :-)
This'll help me a lot with the spawn lets final polish too 👍
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test |
Build failed |
@swift-ci Please smoke test Linux |
TaskGroup
at the .swift levelswift_taskGroup_isCancelled
is implied by the parent task being cancelledTaskGroup
structs@frozen
withTaskGroup
functions@inlinable
swift_taskGroup_create
swift_taskGroup_destroy
To achieve the allocation change, introduce paired create/destroy builtins.
Furthermore, remove the
_swiftRetain
and_swiftRelease
functions and several calls to them. Replace them with uses of the appropriate builtins. I should probably change the builtins to return retained, since they're working with a managed type, but I'll do that in a separate commit.