並行模式庫
来自维基百科,自由的百科全书
並行模式庫(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。
參考文獻
Wikiwand - on
Seamless Wikipedia browsing. On steroids.