Skip to content
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
merged 11 commits into from Jul 7, 2021

Conversation

DougGregor
Copy link
Member

Summary of changes in response to the third review:

  • renamed Task.sleep(_:) to Task.sleep(nanoseconds:). This makes it clear that the wait is in nanoseconds, and leaves API space open for a sleep(_:) based on a better duration type in the future.
  • made Task.sleep(nanoseconds:) throwing; it will throw CancellationError if the sleeping task was cancelled.
  • renamed TaskGroup.async and TaskGroup.asyncUnlessCancelled to TaskGroup.addTask and TaskGroup.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 via next()), we are adding a task whose value will be accessible via next(). It also parallels the use of Task { ... } to create top-level tasks.
  • renamed TaskPriority.default to TaskPriority.medium, because nil passed in to a TaskPriority? parameter is effectively the default for most APIs.
  • added TaskGroup.waitForAll and ThrowingTaskGroup.waitForAll.
  • renamed Task.yield() to Task.suspend(), which more accurately represents what this operation action does, and leaves the name "yield" for future work on generators.

airspeedswift and others added 3 commits July 7, 2021 13:37
Co-authored-by: Ben Rimmington <me@benrimmington.com>
Co-authored-by: Ben Rimmington <me@benrimmington.com>
Co-authored-by: Ben Rimmington <me@benrimmington.com>
@airspeedswift airspeedswift merged commit 8609cad into apple:main Jul 7, 2021
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
Labels
None yet
Projects
None yet
3 participants