并行模式库
并行模式库(Parallel Patterns Library,PPL)是微软的本地C++库用于并发编程。[1] 从Visual Studio 2010引入,很好地兼容于C++11语言标准。
例子
    
对于串行的循环:
  for (int x=0; x < width; ++x)
  {
     //Something parallelizable
  }
可以使用parallel_for改为并行循环实现:
  #include <ppl.h>
  // . . .
 Concurrency::parallel_for (0, width, [=](int x)
 {
     //Something parallelizable
 });
MSDN[2]描述该库使用Concurrency Runtime调度与资源管理,提供通用、类型安全算法与容器。从Visual Studio 2015开始,Concurrency Runtime Task Scheduler不再调度在ppltasks.h中的task类与相关类型,而是用Windows ThreadPool以得到更好性能,以及能与Windows同步原语交互。并行算法如parallel_for继续使用Concurrency Runtime Task Scheduler。
    This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.