-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Implement ForEachAsync in System.Collections.Concurrent #14088
Comments
@stephentoub I'm interested to get your take here. Are there things we can do which do not pull in too much policy to the runtime (or places where we can hit the 99% case where some default choices for policy)? |
I think it'd be a reasonable addition, though I think it'd make sense in a separate library of some kind, along with other more specialized combinators over Tasks. I've been thinking of starting such a project on https://github.com/dotnet/corefxlab. There is a fair amount of policy that would be included, e.g. what to do in the face of exceptions, how much parallelism to employ, whether that's a statement about the number of activities allowed to run concurrently or a statement on how much CPU-bound code to execute concurrently, etc. But I also think we could have some reasonable defaults. |
@stephentoub, what should be the next steps here? |
There are a ton of "1-to-6-liners" like these that can be valuable. The trouble is, different folks need different things with slightly different behaviors here and there. The fact that there are multiple examples earlier in this thread (and there were more in the original blog post(s), plus more that could be written to address some of the considerations I called out in my previous response) highlight that there are lots of different variations folks could want. In such cases, I'm inclined to put the examples out there and let folks piece the primitives together in whatever manner fits their needs best. As I noted, a corefxlabs project could be built (with a NuGet package distributed for it) that contains a bunch of these, and folks can use that NuGet package as they see fit if the included implementations meet their needs. At some point we could promote some of those implementations into the core libraries if we found them to be particularly widely desired and used. I just don't know right now which would actually be important to include in the core libraries, and I'd hate to get it wrong and lead folks down the wrong path. @davidfowl, are you using any of these as-is? Can you elaborate on which and in what scenarios? Is ASP.NET using them? |
@stephentoub We use some of these today in DNU to do things like restore the specified projects in parallel (as an example). |
Which ones? |
Your blog posts concerning tasks, async/await including the discussions comments are indispensable |
I have used this primitive in a more fleshed out form for years now. It should be possible to pick sensible policies and make this into a stable API. There are not that many policies to pick at all. When I wrote this I found the design to be almost forced. For example the DOP must be specified by the caller since there are no good heuristics possible for IO work. Even hill climbing would not work because it might overwhelm the resource you are using/calling. A human must pick the DOP for IO. In case of any exception abort the loop. If users don't want that they are free to catch themselves. There's also a need for cancellation and Many users are using Some users are splitting their input into chunks and then processing the chunk with I think the community would benefit from a high quality and well done implementation of this. I see this need all the time on Stack Overflow. The most awesome thing of all would be an open sourcing of the old |
Yeah, I really need to make time to do that. I'm adding it to my list. |
I think the way to go about doing that is:
Step 1 has to be made by someone from MS (because ParallelExtensionExtras are currently licensed under Microsoft Limited Public License, which is not open source). The community could help with steps 2 and 3. Also, if packages from step 2 are published to NuGet, then step 3 becomes less important. |
Echoing @stephentoub's comments, I think it might make sense to encourage users to author their own variations of the above helper methods. I'm going to close this issue. |
This is a dup anyway of #1946, where much more discussion has happened. |
@stephentoub has some great blog posts about higher level operations that can be implemented all using public API that exists today. Some of these would be great to see in the library itself:
http://blogs.msdn.com/b/pfxteam/archive/2012/03/05/10278165.aspx
In particular
And
The text was updated successfully, but these errors were encountered: