From 12f7a9b40d3dcac13be69ce1537fc9cc8ebe5c39 Mon Sep 17 00:00:00 2001 From: Ryan Sobol Date: Wed, 30 Dec 2020 17:01:58 -0800 Subject: [PATCH 1/2] Fix makeDinnerTaskGroup code example The `makeDinnerTaskGroup()` code example has a couple of potential issues: 1. The `withTaskGroup()` function doesn't seem to be defined or mentioned anywhere else in this proposal. Do you mean `Task.withGroup`? 1. There are no `try await` keywords prepended to the expression initializing the task group. Was this an accidental omission? 1. There is no `return` keyword prepended to the expression either. I'm not sure if this is needed or not; see my [previous pull request](https://github.com/DougGregor/swift-evolution/pull/41). --- proposals/nnnn-structured-concurrency.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proposals/nnnn-structured-concurrency.md b/proposals/nnnn-structured-concurrency.md index 440d58d8dc..8d8096f6d3 100644 --- a/proposals/nnnn-structured-concurrency.md +++ b/proposals/nnnn-structured-concurrency.md @@ -243,7 +243,7 @@ We can then re-implement `makeDinner` with only a task group: ```swift func makeDinnerTaskGroup() async throws -> Meal { - withTaskGroup(resultType: DinnerChildTask.self) { group in + return try await Task.withGroup(resultType: DinnerChildTask.self) { group in await group.add { DinnerChild.chopVegetables(await chopVegetables()) } @@ -260,6 +260,7 @@ func makeDinnerTaskGroup() async throws -> Meal { var meat: Meat? = nil var oven: Oven? = nil var dish: Dish? = nil + while let child = try await group.next() { switch child { case .chopVegetables(let newVeggies): From 874943f6d1c4e453a0c4e1bf783bbdb0d2680a5f Mon Sep 17 00:00:00 2001 From: Ryan Sobol Date: Thu, 31 Dec 2020 07:37:58 -0800 Subject: [PATCH 2/2] Change DinnerChildTask to DinnerChild --- proposals/nnnn-structured-concurrency.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/nnnn-structured-concurrency.md b/proposals/nnnn-structured-concurrency.md index 8d8096f6d3..d03c7f03a6 100644 --- a/proposals/nnnn-structured-concurrency.md +++ b/proposals/nnnn-structured-concurrency.md @@ -243,7 +243,7 @@ We can then re-implement `makeDinner` with only a task group: ```swift func makeDinnerTaskGroup() async throws -> Meal { - return try await Task.withGroup(resultType: DinnerChildTask.self) { group in + return try await Task.withGroup(resultType: DinnerChild.self) { group in await group.add { DinnerChild.chopVegetables(await chopVegetables()) }