This project is read-only.

when_all

defined in header <pplpp.h>
template <typename ... _Ty>
concurrency::task<std::tuple<_Ty...>> when_all(_Ty... tasks)

Summary

Creates a task that will complete successfully when all of the heterogeneous tasks supplied as arguments complete successfully.

Parameters

  • tasks : A list of heterogeneous tasks.

Return values

A task that completes successfully when all of the input tasks have completed successfully.
If the input tasks are task<T1> and task<T2>, the output of this function is task<std::tuple<task<T1>, task<T2>>>

Sample

#include "pplpp.h"
auto pn = std::make_shared<std::atomic_size_t>(0);
concurrency::task<int> t1([=]{
        for (int i = 0; i < 1000000; ++i)
           (*pn)++;
        return 1;
});

concurrency::task<char> t2([pn]{
         for (int i = 0; i < 1000000; ++i)
            (*pn)++;
         return 'c';
});

auto result = pplpp::when_all(t1, t2);
result.then([](std::tuple <concurrency::task <int>, concurrency::task <char> > t){
	std::get<0>(t).get();
});

Last edited Jul 8, 2013 at 10:41 PM by gbb21, version 5

Comments

No comments yet.