24 template <
class InputIterator>
25 typename std::vector<
typename std::enable_if<
28 typename std::iterator_traits<InputIterator>::value_type>,
33 typename std::iterator_traits<InputIterator>::value_type>>>
::type>
36 typename std::iterator_traits<InputIterator>::value_type>
39 assert(std::distance(first, last) >= 0);
40 assert(n <= static_cast<size_t>(std::distance(first, last)));
43 std::vector<std::pair<size_t, Result>> results;
48 Context(
size_t tasksTodo_) : tasksTodo(tasksTodo_) {
49 this->results.reserve(tasksTodo_);
52 auto context = std::make_shared<Context>(n);
56 for (
size_t i = 0; first != last; ++
i, ++
first) {
68 context->e = std::current_exception();
70 if (--
context->tasksTodo == 0) {
77 if (
context->e != std::exception_ptr()) {
78 std::rethrow_exception(
context->e);
84 template <
class InputIterator>
85 typename std::enable_if<
88 typename std::iterator_traits<InputIterator>::value_type>,
93 assert(std::distance(first, last) >= 0);
94 assert(n <= static_cast<size_t>(std::distance(first, last)));
97 std::vector<size_t> taskIndices;
102 Context(
size_t tasksTodo_) : tasksTodo(tasksTodo_) {
103 this->taskIndices.reserve(tasksTodo_);
106 auto context = std::make_shared<Context>(n);
110 for (
size_t i = 0; first != last; ++
i, ++
first) {
122 context->e = std::current_exception();
124 if (--
context->tasksTodo == 0) {
131 if (
context->e != std::exception_ptr()) {
132 std::rethrow_exception(
context->e);
138 template <
class InputIterator>
139 typename std::vector<
140 typename std::enable_if<
143 typename std::iterator_traits<InputIterator>::value_type>,
146 typename std::iterator_traits<InputIterator>::value_type>>
:: 149 typename std::iterator_traits<InputIterator>::value_type>
151 size_t n = size_t(std::distance(first, last));
152 std::vector<Result> results;
153 std::vector<size_t>
order(n);
156 forEach(first, last, [&results, &order](
size_t id, Result result) {
157 order[id] = results.size();
160 assert(results.size() == n);
162 std::vector<Result> orderedResults;
163 orderedResults.reserve(n);
165 for (
size_t i = 0;
i < n; ++
i) {
166 orderedResults.emplace_back(
std::move(results[order[
i]]));
169 return orderedResults;
172 template <
class InputIterator>
173 typename std::enable_if<
176 typename std::iterator_traits<InputIterator>::value_type>,
179 forEach(first, last, [](
size_t ) {});
182 template <
class InputIterator>
183 typename std::enable_if<
186 typename std::iterator_traits<InputIterator>::value_type>,
191 typename std::iterator_traits<InputIterator>::value_type>>>
:: 193 auto result =
collectN(first, last, 1);
194 assert(result.size() == 1);
198 template <
class InputIterator>
199 typename std::enable_if<
202 typename std::iterator_traits<InputIterator>::value_type>,
205 auto result =
collectN(first, last, 1);
206 assert(result.size() == 1);
std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, typename std::pair< size_t, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > >::type collectAny(InputIterator first, InputIterator last)
std::vector< typename std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > >::type > collectAll(InputIterator first, InputIterator last)
typename invoke_result< F, Args... >::type invoke_result_t
constexpr detail::Map< Move > move
std::vector< typename std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, typename std::pair< size_t, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > >::type > collectN(InputIterator first, InputIterator last, size_t n)
—— Concurrent Priority Queue Implementation ——
void forEach(InputIterator first, InputIterator last, F &&f)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
constexpr detail::First first
FirstArgOf< F >::type::value_type await(F &&func)