CLI: Rewrite ForEachAsync to use threadpool, add timeout#40675
Open
dkbennett wants to merge 8 commits into
Open
CLI: Rewrite ForEachAsync to use threadpool, add timeout#40675dkbennett wants to merge 8 commits into
dkbennett wants to merge 8 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR rewrites the WSLC ForEachAsync helper to use the Windows thread pool with bounded concurrency and cooperative cancellation, then updates container stats collection and unit coverage to use the new API.
Changes:
- Replaces
std::asyncbatch execution with a reusable thread-pool worker implementation. - Adds timeout/cancel-drain parameters and updates container stats to pass a cancellation handle.
- Expands unit tests for pool sizing, dispatching beyond the initial pool, timeout, and cancellation behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/windows/wslc/core/AsyncExecution.h |
Reimplements ForEachAsync with thread-pool workers, cancellation, and timeout handling. |
src/windows/wslc/tasks/ContainerTasks.cpp |
Updates stats collection to the new ForEachAsync signature and timeout parameters. |
test/windows/wslc/WSLCCLIExecutionUnitTests.cpp |
Updates existing tests and adds coverage for new pool and timeout behaviors. |
Comment on lines
+234
to
+236
| // If onSuccess, onError, or Launch throw, the cancel event is signalled and ForEachAsync | ||
| // waits up to cancelDrainTimeout for any in-flight workers to exit before rethrowing. | ||
| // This guarantees no background thread pool callbacks outlive the ForEachAsync call. |
This file contains hidden or 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
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 the Pull Request
This is an improvement of the ForEachAsync generic method to use the windows thread pool and keep the pool full of workers whenever one completes instead of waiting for every worker to be complete before starting another batch. This also adds a timeout to the method so workers do not execute endlessly and does some refactoring for easier debugging.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed