Using Parallel Patterns Library (ppl.h)

I'm trying to learn how to use ppl.h in c++ . But I'm not sure what kind of solution I should create in VS2010 to use it. If i create a Win32 Console app without CLR'concurrency' is not recognized and if i create Win32 Console app with CLR i get an error saying

Concurrency Runtime is not supported when compiling /clr.

#include "stdafx.h" #include <ppl.h> using namespace System; void BubbleSort(int* input, int n) { concurrency::parallel_for(0,n,[=](int y) { for(int k = 0; k< n - 1 -y; k++) { if(input[k]> input[k+1]) { auto temp = input[k+1]; input[k+1] = input[k]; input[k] = temp; } } } } int main(array<System::String ^> ^args) { Console::WriteLine(L"Hello World"); return 0; } 
0

1 Answer

You can make a Win32 Console Application (no CLR). Once you #include <ppl.h>, the Concurrency namespace should be available. Note that it's Concurrency::parallel_for (captial "C").

For details, see the PPL example on MSDN.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like