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
[SE-0304] Update Structured Concurrency proposal based on feedback from the third review #1406
Merged
airspeedswift
merged 11 commits into
apple:main
from
DougGregor:structured-concurrency-3
Jul 7, 2021
Merged
[SE-0304] Update Structured Concurrency proposal based on feedback from the third review #1406
airspeedswift
merged 11 commits into
apple:main
from
DougGregor:structured-concurrency-3
Jul 7, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The use of the adjective `async` for creating new child tasks was too confusing and didn't fit well with the naming guidelines. Instead, use `addTask`, which makes it clear that we are adding a new task into a task group (the result of which is available via `next()`).
Co-authored-by: Ben Rimmington <me@benrimmington.com>
Co-authored-by: Ben Rimmington <me@benrimmington.com>
Co-authored-by: Ben Rimmington <me@benrimmington.com>
mattt
pushed a commit
to mattt/swift-evolution
that referenced
this pull request
Aug 17, 2021
…om the third review (apple#1406) * [SE-0304] Replace `TaskGroup.async` with `TaskGroup.addTask`. The use of the adjective `async` for creating new child tasks was too confusing and didn't fit well with the naming guidelines. Instead, use `addTask`, which makes it clear that we are adding a new task into a task group (the result of which is available via `next()`). * [SE-0304] Rename `sleep(_:)` to `sleep(nanoseconds:)`. * [SE-0304] Split out changes due to review apple#3 * [SE-0304] Rename TaskPriority.default to TaskPriority.medium * [SE-0304] Add (Throwing)?TaskGroup.waitForAll * [SE-0304] Rename `Task.yield()` to `Task.suspend()` * [SE-0304] Make `Task.sleep(nanoseconds:)` throwing on cancellation * Re-schedule review
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes in response to the third review:
Task.sleep(_:)
toTask.sleep(nanoseconds:)
. This makes it clear that the wait is in nanoseconds, and leaves API space open for asleep(_:)
based on a better duration type in the future.Task.sleep(nanoseconds:)
throwing; it will throwCancellationError
if the sleeping task was cancelled.TaskGroup.async
andTaskGroup.asyncUnlessCancelled
toTaskGroup.addTask
andTaskGroup.addTaskUnlessCancelled
. The fundamental behavior here is that we're adding a task to the group.add
by itself does not suffice, because we aren't adding a value (accessible vianext()
), we are adding a task whose value will be accessible vianext()
. It also parallels the use ofTask { ... }
to create top-level tasks.TaskPriority.default
toTaskPriority.medium
, becausenil
passed in to aTaskPriority?
parameter is effectively the default for most APIs.TaskGroup.waitForAll
andThrowingTaskGroup.waitForAll
.Task.yield()
toTask.suspend()
, which more accurately represents what this operation action does, and leaves the name "yield" for future work on generators.