MCPcopy Create free account
hub / github.com/boostorg/asio / parallel_sort_impl

Function parallel_sort_impl

example/cpp14/parallel_group/parallel_sort.cpp:33–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 typename Executor,
32 typename RandomAccessIterator>
33void parallel_sort_impl(
34 Executor executor,
35 RandomAccessIterator begin,
36 RandomAccessIterator end,
37 std::function<void()> continuation)
38{
39 std::size_t n = end - begin;
40 if (n <= 16384)
41 {
42 boost::asio::post(executor,
43 [=]
44 {
45 std::sort(begin, end);
46 continuation();
47 }
48 );
49 }
50 else
51 {
52 boost::asio::experimental::make_parallel_group(
53 [=](auto token)
54 {
55 return parallel_sort(executor, begin, begin + n / 2, token);
56 },
57 [=](auto token)
58 {
59 return parallel_sort(executor, begin + n / 2, end, token);
60 }
61 ).async_wait(
62 boost::asio::experimental::wait_for_all(),
63 [=](std::array<std::size_t, 2>)
64 {
65 std::inplace_merge(begin, begin + n / 2, end);
66 continuation();
67 }
68 );
69 }
70}
71
72template <
73 typename Executor,

Callers 1

parallel_sortFunction · 0.85

Calls 4

parallel_sortFunction · 0.85
wait_for_allClass · 0.85
postFunction · 0.50
async_waitMethod · 0.45

Tested by

no test coverage detected