| 31 | typename Executor, |
| 32 | typename RandomAccessIterator> |
| 33 | void 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 | |
| 72 | template < |
| 73 | typename Executor, |
no test coverage detected