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

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.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest