有序的ForAll PLINQ [英] Ordered PLINQ ForAll

查看:135
本文介绍了有序的ForAll PLINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PLINQ 国家有关为了保全MSDN文档以下有关的ForAll()


  • 结果当源序列订购不确定地并行执行不确定地并行

  • 结果当源序列的无序执行EM>

  • Result when the source sequence is ordered: Executes nondeterministically in parallel
  • Result when the source sequence is unordered: Executes nondeterministically in parallel

这是否意味着下令的ForAll 方法的执行是永远不会保证?

Does this mean that ordered execution of the ForAll method is never guaranteed?

我没有用之前PLINQ,但以下代码审查问题似乎为它的适当使用。在我的回答底部我写的:

I haven't used PLINQ before, but the following Code Review question seemed like an appropriate usage for it. At the bottom of my answer I write:

Events.AsParallel().AsOrdered().ForAll( eventItem =>
{
    ...
} );    



看完我相信文档后, AsOrdered()不会改变什么吗?我也怀疑其中,顺序很重要,前面的查询不能代替一个简单的for循环?大概到StringBuilder并行调用也会发生,导致错误的输出?

After reading the documentation I believe the AsOrdered() wouldn't change anything? I'm also suspecting the previous query can't replace a simple for loop where order is important? Probably parallel calls to the StringBuilder will also occur, resulting in a wrong output?

推荐答案

订单保留通常只适用于结果的 - 即输入可以的处理的任何顺序,但的返回的原始顺序

Order preservation is usually only applied to results - i.e. the input can be processed in any order, but is returned in the original order.

由于的ForAll 不返回任何东西,它并没有真正有一个我所知道的任何影响。

As ForAll doesn't return anything, it doesn't really have any effect that I'm aware of.

使得订货申请的唯一途径的处理的将是处理第1项之前完成项目0,加工项目2等前......此时你有没有并行

The only way of making ordering apply to the processing would be to finish item 0 before processing item 1, before processing item 2 etc... at which point you've got no parallelism.

这篇关于有序的ForAll PLINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆