Skip to content

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Dec 2, 2022

Defined by SE-0381: https://github.com/apple/swift-evolution/blob/main/proposals/0381-task-group-discard-results.md


This optimization work is to enable "infinite" task groups which just keep adding tasks "forever" but don't really need child task return values - for example, when implementing an RPC or web server, one might want to use a task group in order to stay inside structured concurrency for benefits of efficiency, task-local inheritance and canceling all in-flight rpcs when the server is cancelled.

Naively trying to handle such server case with:

    try await withThrowingDiscardingTaskGroup() { group in
        for try await query in dnsQuerySequence {
            group.addTask {
                handleQuery(query)
            }
        }
    }

Resolves rdar://101965913

@ktoso ktoso added the concurrency Feature: umbrella label for concurrency language features label Dec 2, 2022
@ktoso ktoso force-pushed the wip-task-group-discardResults branch 2 times, most recently from ee5e3ea to bac9182 Compare December 19, 2022 04:06
@ktoso
Copy link
Contributor Author

ktoso commented Dec 20, 2022

@swift-ci please smoke test

@ktoso ktoso force-pushed the wip-task-group-discardResults branch from 5174f8f to 4bd1099 Compare December 20, 2022 12:04
@ktoso
Copy link
Contributor Author

ktoso commented Dec 20, 2022

Uff, good, caught an accidental dumb ABI problem, fixed and this should be a good first cut.

I'll finish up error and cancellation handling a bit more tomorrow.

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Dec 20, 2022

@swift-ci please smoke test

1 similar comment
@ktoso
Copy link
Contributor Author

ktoso commented Dec 20, 2022

@swift-ci please smoke test

@ktoso ktoso added the swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented label Dec 22, 2022
@ktoso ktoso changed the title [Concurrency] TaskGroup with discardResults [Concurrency][SE-0381] TaskGroup with discardResults Dec 22, 2022
@ktoso ktoso changed the title [Concurrency][SE-0381] TaskGroup with discardResults [Concurrency][SE-0381] DiscardingTaskGroup Dec 22, 2022
@ktoso
Copy link
Contributor Author

ktoso commented Dec 28, 2022

@swift-ci please smoke test

@ktoso ktoso force-pushed the wip-task-group-discardResults branch from 28c7c8b to 60ee652 Compare January 5, 2023 07:19
@ktoso
Copy link
Contributor Author

ktoso commented Jan 5, 2023

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Jan 5, 2023

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Jan 9, 2023

This is "complete" but there's a PR with more code-reuse incoming...

@ktoso
Copy link
Contributor Author

ktoso commented Jan 9, 2023

Replaced by #62914

@ktoso ktoso closed this Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

concurrency Feature: umbrella label for concurrency language features swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant