读书频道 > 网站 > 网页设计 > Visual C++并行编程实战:多核架构下分工与协作的设计模式
2.2.2 parallel_for_each版的Credit Review
12-08-13    叶孤城
收藏    我要投稿   
这本书所介绍的并行模式库(Parallel Patterns Library,PPL)实际上是一个模式化的C++模版库,而且作为Visual Studio 2010开发系统的一部分,它已经完全被内置到了这一版本的C++语言中。这意味着你可以像使...立即去当当网订购
并行版的信用度分析程序与串行版本几乎相差无几: 
void UpdatePredictionsParallel(AccountRepository& accounts) 

       parallel_for_each(accounts.begin(), accounts.end(), 
       [      ] 
       (AccountRepository::value_type& record) 
       { 
              Account& account = record.second; 
              Trend trend = Fit(account.Balances()); 
              double prediction = PredictIntercept(trend, 
                     (account.Balances().size() + g_predictionWindow)); 
              account.ParPrediction() = prediction; 
              account.ParWarning() = prediction < account.GetOverdraft(); 
       }); 

如你所见,除了用parallel_for_each替代for_each外,UpdatePredictionsParallel方法的代码与UpdatePredictionsSequential几乎完全一致
点击复制链接 与好友分享!回本站首页
分享到: 更多
您对本文章有什么意见或着疑问吗?请到论坛讨论您的关注和建议是我们前行的参考和动力  
上一篇:1.3 功能
下一篇:1.5 小结
相关文章
图文推荐
JavaScript网页动画设
1.9 响应式
1.8 登陆页式
1.7 主题式
排行
热门
文章
下载
读书

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训
版权所有: 红黑联盟--致力于做最好的IT技术学习网站