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

Port runtime's Parallel.ForEachAsync so we can use it on NetFx. #73332

Merged
merged 11 commits into from
May 3, 2024

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 3, 2024
#if false
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(body);
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now, just disabling the arg checks internally. we rarely ever check this with our ienumerable helpers.

// Convenience property used by TPL logic
private static TaskScheduler EffectiveTaskScheduler(ParallelOptions options) => options.TaskScheduler ?? TaskScheduler.Current;

private static int EffectiveMaxConcurrencyLevel(ParallelOptions options)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ported these two helpers over as well. they're normally internal properties on ParallelOptions, so we don't have direct access to them anymore.

}

#if false
/// <summary>Executes the task body using the <see cref="ExecutionContext"/> captured when ForEachAsync was invoked.</summary>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be ok. checking with @stephentoub .

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review May 3, 2024 19:24
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 3, 2024 19:24
@CyrusNajmabadi
Copy link
Member Author

@ToddGrun this is ready for review. Will be holding off from merging this until i get OK from stephen on the changes i made.

@CyrusNajmabadi
Copy link
Member Author

Ok. Looks like Stephen is good. @ToddGrun this is ready for review.

#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods

// Ported from
// https://github.com/dotnet/runtime/blob/main/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.ForEachAsync.cs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be very clear. this is effectively the runtime's code. just tweaked as little as possible to get working on netfx.

i do not want to change it beyond that, as that will be much harder to keep in sync and validate against the netcore impl.

@ToddGrun
Copy link
Contributor

ToddGrun commented May 3, 2024

Did a cursory review, I'm going to trust Stephen and Cyrus on this one.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit a87dcac into dotnet:main May 3, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the portForEachAsync2 branch May 3, 2024 23:44
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 3, 2024
@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski For review when you get back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants