PPL container sample

Sample showing some PPL containers.

#include <ppl.h>
#include <concurrent_vector.h>
#include <concurrent_queue.h>
 
using namespace Concurrency;
 
// =================================================================================================
 
void cont_concurrent_vector()
{
    concurrent_vector<int> vec;
    parallel_for((size_t)0, (size_t)1000,
                 [&](size_t i) { vec.push_back(i); });
}
 
// =================================================================================================
 
void cont_concurrent_queue()
{
    concurrent_queue<int> queue;
    parallel_for((size_t)0, (size_t)1000,
                 [&](size_t i) { queue.push(i); });
 
    std::cout << "queue has " << queue.unsafe_size() << " elements" << std::endl;
}
 
// =================================================================================================
 
void cont_combinable()
{
    int arr[] = { 1, 2, 3, 4, 5};
 
    combinable<int> comb;
    parallel_for_each(&arr[0], &arr[5], [&](int value) { comb.local() += value; });
    int res = comb.combine([&](int acc, int value) { return acc+value; });
 
    std::cout << "combinable = " << res << std::endl;
}